Make overlay button with transparent background color - kotlin

I try to create overlay button with transparent background, but it's not fully transparent.
I set a transparent background color and transparent theme, but still I can observe background of this button. Ideally, it should be oval overlay button without additional background.
#SuppressLint("ResourceAsColor")
private fun createButton(){
overlayButton = ImageButton(this)
overlayButton.setBackgroundColor(R.color.transparentColor)
overlayButton.setImageResource(R.drawable.ready_button)
overlayButton.setOnTouchListener(this)
overlayButton.setOnClickListener(this)
val layoutFlag = if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
}
else {
Toast.makeText(this,"Old-fashioned model", Toast.LENGTH_SHORT).show()
WindowManager.LayoutParams.TYPE_APPLICATION
}
params = WindowManager.LayoutParams()
params.gravity = Gravity.TOP or Gravity.START
params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
params.type = layoutFlag
params.width = (mWidth*0.2).roundToInt()
params.height = (mWidth*0.2).roundToInt()
params.x = mWidth
params.y = (mHeight*0.15).roundToInt()
params.format = PixelFormat.TRANSPARENT
wmgr.addView(overlayButton,params)
}
ready_button.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:background="#0000000">
<gradient
android:angle="90"
android:startColor="#color/readyColor1"
android:endColor="#color/readyColor2" />
<corners android:radius="1000dp" />
</shape>
in colors I have this color:
<color name="transparentColor" >#00000000</color>
Used style in this service window:
<style name="Theme.AppCompat.Translucent" parent="Theme.AppCompat.NoActionBar">
<item name="android:background">#color/transparentColor</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">#android:style/Animation</item>
</style>

Related

Theme ActionBar text title color issue with MaterialComponents.DayNight.DarkActionBar

I am struggling to set the dark and light mode theme color's for the title text and the background color.
My themes.xml code:
<style name="Theme.Main" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="android:textColorPrimary">#color/colorAccent</item> //PrefScreen text
<item name="android:textColorSecondary">#color/colorAccent</item> //PrefScreen summary
<item name="colorPrimary">#color/background_dark</item> //ActionBar background
<item name="colorSecondary">#color/colorPrimary</item> //fab outline, PrefCategory
<item name="colorOnSecondary">#color/OnSecN</item> //fab icon
<item name="android:windowLightStatusBar" tools:targetApi="23">false</item>
<item name="android:statusBarColor" tools:targetApi="l">#color/background_dark</item>
<item name="android:backgroundTint">#color/background_dark</item>
</style>
Theme is applied in AndroidManifest.xml to application.
I have tried textColor and titleTextColor.

How to tap on the three dot menu (more options) in the actionbar on Android using Detox?

How to tap on the three dot menu (more options) in the actionbar on Android using Detox?
I followed this SO answer, https://stackoverflow.com/a/65736139/3970346
Since this is a NativeScript app the steps are,
Create a ids.xml file under app/App_Resources/Android/src/main/res/values folder,
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item type="id" name="overflowActionButton"/>
</resources>
Then in the styles.xml in the same directory add,
<style name="Widget.ActionButton.Overflow" parent="Widget.AppCompat.ActionButton.Overflow">
<item name="android:id">#id/overflowActionButton</item>
<item name="android:contentDescription">"overflowActionButton"</item>
<item name="android:tint">#color/white</item>
</style>
Finally set the style on the AppThemeBase like this,
<!-- theme to use AFTER launch screen is loaded-->
<style name="AppThemeBase" parent="Theme.AppCompat.Light.NoActionBar">
<item name="toolbarStyle">#style/NativeScriptToolbarStyle</item>
<item name="colorPrimary">#color/ns_primary</item>
<item name="colorPrimaryDark">#color/ns_primaryDark</item>
<item name="colorAccent">#color/ns_accent</item>
<!-- the line below -->
<item name="actionOverflowButtonStyle">#style/Widget.ActionButton.Overflow</item>
</style>
After this you can tap on the overflow menu in Detox like this,
await element(by.label('overflowActionButton')).tap();
Thanks to #Leri Gogsadze for pointing me in the right direction

Appcelerator Titanium: How do I change SearchView colors on Android? (hintText and cross icon)

I have a SearchView which is dark and its hinttext and its cross icon are black, so I want to set the color of these two things to white.
I am using a custom theme for Android but it does nothing to the SearchView. This is how my custom theme xml file looks like:
<resources>
<style name="Theme.MyApp" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:spinnerItemStyle">#style/MySpinnerItem</item>
<item name="android:actionBarStyle">#style/SearchViewTheme</item>
</style>
<style name="SearchViewTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:textColorPrimary">#FFFFFF</item>
<item name="android:textColorSecondary">#FFFFFF</item>
<item name="android:textColorHint">#CCCCCC</item>
</style>
<style name="MySpinnerItem" parent="#android:style/Widget.TextView.SpinnerItem">
<item name="android:paddingTop">10dp</item>
<item name="android:paddingBottom">10dp</item>
<item name="android:paddingLeft">10dp</item>
<item name="android:textSize">14dp</item>
</style>
</resources>
I found a solution. If anyone wants to know what I did:
I just deleted this line:
<item name="android:actionBarStyle">#style/SearchViewTheme</item>
And then, I added this to the .tss file where the SearchView is:
"Window[platform=android]" : {
theme : "SearchViewTheme"
}

React Native ,why can't I align picker item to right in android platform?

I tried to find the solution for ages , but it's still none working! Below is how I wrote:
<View style = {[ {flex: 0.7} ]}>
<Picker
selectedValue={this.state.selectedGender}
onValueChange={this.onValueChange.bind(this, 'selectedGender')}
>
<Item label="Please select gender" value=""/>
<Item label="Male" value="M" />
<Item label="Female" value="F" />
</Picker>
</View>
If you want to change the style of the picker items on Android, you have to change native code.
You'll have to add your style in android/app/src/main/res/values/styles.xml.
To change the picker container
Here I set, the background to null so there is not the down arrow on the left.
<style name="SpinnerStyle" parent="#android:style/Widget.Spinner">>
<item name="android:background">#null</item>
</style>
To change the selected item style
Here I set the items to be centered, the color font to be dark gray and the font size to 16.
<style name="SpinnerItem" parent="Theme.AppCompat.Light.NoActionBar">>
<item name="android:gravity">center</item>
<item name="android:textColor">#373737</item>
<item name="android:textSize">16dp</item>
</style>
To change the drapdown items
Just as, the selected item, I want the dropdown items to have the same style.
<style name="SpinnerDropDownItem" parent="Theme.AppCompat.Light.NoActionBar">>
<item name="android:gravity">center</item>
<item name="android:textColor">#373737</item>
<item name="android:textSize">16dp</item>
</style>
Finally
Once, you have set your styles for every element of the picker. You have to add the style to the general App theme.
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
...
<item name="android:spinnerStyle">#style/SpinnerStyle</item>
<item name="android:spinnerItemStyle">#style/SpinnerItem</item>
<item name="android:spinnerDropDownItemStyle">#style/SpinnerDropDownItem</item>
...
</style>
Hope it helps !

How to Stop/Reset AnimationDrawable in Android

Animation drawable is not "stopping".
I want to reset animation drawable when I click on the another button.
Code for starting animation drawable:
MainActivity:
private AnimationDrawable frameAnimation
iconConnecting.setBackgroundResource(R.drawable.frame_animation);
frameAnimation = (AnimationDrawable) iconConnecting.getBackground();
frameAnimation.start();
frame_animation.xml:
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="#drawable/connecting0" android:duration="400" />
<item android:drawable="#drawable/connecting1" android:duration="400" />
<item android:drawable="#drawable/connecting2" android:duration="400" />
<item android:drawable="#drawable/connecting3" android:duration="400" />
<item android:drawable="#drawable/connecting4" android:duration="400" />
</animation-list>
In frame_animation.xml, change android:oneshot value to true
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
Documentation of android:oneshot:
"If true, the animation will only run a single time and then stop. If false (the default), it will continually run, restarting at the first frame after the last has finished."