android-theme

How to get a value of color attribute programmatically

馋奶兔 提交于 2020-03-18 05:21:06
问题 When I use resolveAttribute() to find out a color value of ?attr/colorControlNormal , I got 236 : TypedValue typedValue = new TypedValue(); getTheme().resolveAttribute(R.attr.colorControlNormal, typedValue, true); int color = typedValue.data; // 236 But when I use an XML layout with the following TextView element: <TextView android:id="@+id/textView" style="?android:attr/textAppearance" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="?attr

How to get a value of color attribute programmatically

痞子三分冷 提交于 2020-03-18 05:20:29
问题 When I use resolveAttribute() to find out a color value of ?attr/colorControlNormal , I got 236 : TypedValue typedValue = new TypedValue(); getTheme().resolveAttribute(R.attr.colorControlNormal, typedValue, true); int color = typedValue.data; // 236 But when I use an XML layout with the following TextView element: <TextView android:id="@+id/textView" style="?android:attr/textAppearance" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="?attr

How to get a value of color attribute programmatically

爱⌒轻易说出口 提交于 2020-03-18 05:20:03
问题 When I use resolveAttribute() to find out a color value of ?attr/colorControlNormal , I got 236 : TypedValue typedValue = new TypedValue(); getTheme().resolveAttribute(R.attr.colorControlNormal, typedValue, true); int color = typedValue.data; // 236 But when I use an XML layout with the following TextView element: <TextView android:id="@+id/textView" style="?android:attr/textAppearance" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="?attr

Dark theme android app

╄→гoц情女王★ 提交于 2020-03-17 12:00:10
问题 I'm trying to create a dark theme similar to the one in OxygenOS on OnePlus devices. I changed the window background to black but the problem is the action bar is not becoming pure black. <style name="DarkTheme" parent="Theme.AppCompact"> <item name="android:colorPrimary">@color/black</item> <item name="android:colorPrimaryDark">@color/black</item> <item name="android:textColorPrimary">@color/white</item> <item name="android:colorAccent">@color/white</item> <item name="android:color">@color

Android DarkMode : Value night not working

我的未来我决定 提交于 2020-03-15 06:41:07
问题 I am developing Day/Night feature in my app so I read those documents and start developing it. It's working fine with default value in Day or Night with deligate method AppCompatDelegate.setDefaultNightMode(*) . For customize night theme color I create values-night folder and inside I create colors.xml file like below. res -> values -> colors.xml res -> values-night -> colors.xml After I place that color but not applying in Night theme! Its very strange why value-night colors is not applying

Android Actionbar navigation spinner text color

二次信任 提交于 2020-02-10 08:17:07
问题 I am able to change the background of the navigation spinner: <style name="MyTheme" parent="android:style/Theme.Light"> <item name="android:actionBarStyle">@style/MyActionBar</item> <item name="android:actionDropDownStyle">@style/MyDropDownNav</item> </style> <style name="MyDropDownNav" parent="android:style/Widget.Spinner"> <item name="android:background">@drawable/spinner_white</item> <item name="android:textColor">@color/red</item> </style> Nevertheless the textColor is not changed. I also

android:Theme.Material.Light requires API level 21 (current min is 8)

旧城冷巷雨未停 提交于 2020-01-30 14:29:29
问题 I want to use Material Theme in my application which has minimum sdk version of 8. As per docs - "The material theme is only available in Android 5.0 (API level 21) and above. The v7 Support Libraries provide themes with material design styles for some widgets and support for customizing the color palette." Does it mean I can use it if I add v7 Support Libarary in my project? Because after adding this library I got the following error: android:Theme.Material.Light requires API level 21

Detect the Android device theme (is it dark or light)

断了今生、忘了曾经 提交于 2020-01-24 08:50:51
问题 You can set the theme for your app, but I'm wondering if it's possible to find out which one is used by the device. Currently, my app uses Theme.AppCompat.Light . I'd like to avoid changing the theme. P.S. I've already tried to set it to Theme.DeviceDefault and access its ID using reflection, but no luck so far. try { setTheme(android.R.style.Theme_DeviceDefault); Class<Context> contextClass = Context.class; Method getThemeMethod = contextClass.getMethod("getThemeResId"); getThemeMethod

Detect the Android device theme (is it dark or light)

你离开我真会死。 提交于 2020-01-24 08:49:45
问题 You can set the theme for your app, but I'm wondering if it's possible to find out which one is used by the device. Currently, my app uses Theme.AppCompat.Light . I'd like to avoid changing the theme. P.S. I've already tried to set it to Theme.DeviceDefault and access its ID using reflection, but no luck so far. try { setTheme(android.R.style.Theme_DeviceDefault); Class<Context> contextClass = Context.class; Method getThemeMethod = contextClass.getMethod("getThemeResId"); getThemeMethod

Theme not applied using appcompat library on some Android 4.X devices

醉酒当歌 提交于 2020-01-22 17:57:12
问题 After updating the appcompat library to the latest version (v21) to apply the material design, my custom theme isn't used anymore on Android 4.0.X devices unless I explicitly declare it in the XML. I have tested the theme on Android 2.3.X and 5.0.0 devices and it works on those devices. But it's not working on my HTC One S with Android 4.0.3. What do I need to do to fix this? My themes.xml <style name="Theme.Custom" parent="@style/Theme.AppCompat.Light"> <item name="android:editTextStyle">