android-theme

Android application theme change smoothly

…衆ロ難τιáo~ 提交于 2020-06-26 21:22:44
问题 I am working on a project where day and night themes available. I am changing themes by night theme: AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES) day theme: AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO) But to see the changes in that activity/app, I need to restart app or recreaate that activity by recreate() but this is taking time and its not smooth like whatsApp or Telegram. So how could I change theme of app smoothly that looks beautiful

Android set transparent background for a fragment

旧城冷巷雨未停 提交于 2020-06-11 16:53:06
问题 In my app I have single activity and and all other fragments I am setting background for activity from style.xml as below <item name="android:windowBackground">@color/very_light_gray</item> Now for only a perticular Fragment I want to set background transparent and I am not able to do that tried below code in Fragment did not work for me @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // create ContextThemeWrapper from the original

Get an EditText's 'default' color value from theme

孤街醉人 提交于 2020-05-14 17:44:28
问题 I have an Activity that contains an EditText on 3.1. Based on user input, I change the color of the text in the EditText (red for an error), and then reset it to black when the text is OK. One issue relates to changing the overall theme of the Activity. For instance, changing it to the regular dark theme from the light theme results in the black text being shown against a black background - so I need to go in and change the code, instead resetting the text to white when the data is OK.

Changing theme of an activity without recreating activity

和自甴很熟 提交于 2020-05-13 07:55:26
问题 I have an activity . In that on a button click I want to change the theme but everywhere I found that theme can be set only once and that too before setContentView. Restarting an activity is not an option for me. Maybe using attrs has to do something with this problem. But I have no idea how to use it. Please Help!! Thanks in advance!! 回答1: No that is not possible, from the relevant documentation: public void setTheme (int resid) Set the base theme for this context. Note that this should be

Android: How to switch theme for dark mode?

橙三吉。 提交于 2020-04-30 07:05:07
问题 Since Android 10, you can switch between dark mode and default light mode. I didn't make any closer research yet on this since it's a new topic. Is Dark mode color switching automatic by OS or is there any way to tell my App to switch different app-theme if Dark mode is turned on? Also dark mode is possibility for some Android 9 devices. Because I made custom Dark theme with custom parameters and I set dark color for each of my color in resources (using custom attributes in attrs.xml and

Compiler error when applying theme with databinding

为君一笑 提交于 2020-04-18 05:42:14
问题 My code shuffles colors and indexes for a list of ColorBox objects indefinitely. This is my view: <TextView style="@style/App.WidgetStyle.ColorBox" android:text="@{item.id}" android:theme="@{item.theme}" tools:text="A" tools:theme="@style/App.ColorBox" /> My styles: <style name="App.WidgetStyle.ColorBox" parent="App"> <item name="android:layout_width">@dimen/square_size</item> <item name="android:layout_height">@dimen/square_size</item> <item name="android:background">@drawable/shape_for

force dark mode in android is not responding

浪尽此生 提交于 2020-04-17 20:25:09
问题 I am trying to implement dark theme as described here. So, I have created arrays.xml as: <resources> <array name="themes_labels"> <item>"Default"</item> <item>"Light"</item> <item>"Dark"</item> </array> <string-array name="themes_color"> <item>"Default"</item> <item>"Light"</item> <item>"Dark"</item> </string-array> </resources> and this is my code to change the theme, which is not working, i.e., the theme is not changing, though the first Toast is giving correct value, where the 2nd Toast

force dark mode in android is not responding

徘徊边缘 提交于 2020-04-17 20:23:37
问题 I am trying to implement dark theme as described here. So, I have created arrays.xml as: <resources> <array name="themes_labels"> <item>"Default"</item> <item>"Light"</item> <item>"Dark"</item> </array> <string-array name="themes_color"> <item>"Default"</item> <item>"Light"</item> <item>"Dark"</item> </string-array> </resources> and this is my code to change the theme, which is not working, i.e., the theme is not changing, though the first Toast is giving correct value, where the 2nd Toast

How to get boolean from custom boolean attribute for current theme?

我的未来我决定 提交于 2020-03-25 19:27:11
问题 I am setting custom attribute with Boolean format in my theme. <attr name="isCompound" format="boolean" /> When I am trying to retrieve this attribute in my code using following TypedValue typedValue = new TypedValue(); getTheme().resolveAttribute(R.attr.isCompound, typedValue, true); if(typedValue.data) { ... } I get error that typedValue.data (int) can not be converted to Boolean. My question is how do I get Boolean value isCompound from the current theme? 回答1: Thanks to @Mike M. for the

How to get boolean from custom boolean attribute for current theme?

依然范特西╮ 提交于 2020-03-25 19:27:04
问题 I am setting custom attribute with Boolean format in my theme. <attr name="isCompound" format="boolean" /> When I am trying to retrieve this attribute in my code using following TypedValue typedValue = new TypedValue(); getTheme().resolveAttribute(R.attr.isCompound, typedValue, true); if(typedValue.data) { ... } I get error that typedValue.data (int) can not be converted to Boolean. My question is how do I get Boolean value isCompound from the current theme? 回答1: Thanks to @Mike M. for the