android-styles

How to get accent color programmatically?

拈花ヽ惹草 提交于 2019-11-27 11:50:20
问题 How would one fetch the accent color set in styles, like below, programmatically? <item name="android:colorAccent">@color/material_green_500</item> 回答1: You can fetch it from the current theme in this way: private int fetchAccentColor() { TypedValue typedValue = new TypedValue(); TypedArray a = mContext.obtainStyledAttributes(typedValue.data, new int[] { R.attr.colorAccent }); int color = a.getColor(0, 0); a.recycle(); return color; } 回答2: This worked for me as well: public static int

Transparent status bar not working with windowTranslucentNavigation=“false”

痴心易碎 提交于 2019-11-27 11:02:21
I am developing an Activity where I need to make the navigation bar opaque, and the status bar transparent on devices running 5.0+ (API 21+). The styles I am using are below, along with an explanation of my problem. AppTheme extends Theme.AppCompat.Light.NoActionBar <item name="android:statusBarColor">@color/transparent</item> <item name="android:windowActionBar">false</item> <item name="android:windowDrawsSystemBarBackgrounds">true</item> <item name="android:statusBarColor">@color/welbe_red_transparent</item> FullscreenTheme extends AppTheme <item name="android:windowNoTitle">true</item>

How to change the style of a DatePicker in android?

对着背影说爱祢 提交于 2019-11-27 10:57:22
I want to change the default color of the date/time picker dialog in Android, so that it should match my app's theme. I searched for the solution on Google, but I couldn't find a solution. What I was doing was creating a new style: <style name="datepicker" parent="@android:style/Widget.DeviceDefault.DatePicker"> <!---TODO--> <item name="android:focusedMonthDateColor">@android:color/holo_red_dark</item> </style> Don't know what are the attributes available for date picker dialogue. It would be great if anyone could post a link on that and after adding the style I was calling it in my main style

Difference between android:windowBackground and android:colorBackground?

元气小坏坏 提交于 2019-11-27 10:29:31
问题 What is the difference between android:windowBackground and android:colorBackground ? Example: <style name = "theme"> <item name ="android:windowBackground">@color/black</item> <item name ="android:colorBackground">@color/black</item> </style> Which one would affect the color you see when a new activity is loading? 回答1: windowBackground only affects the main window's background. colorBackground affects not only the background of the main window but also of all components e.g. dialogs unless

Android actionbar style ignored by later devices, using appcompat v7

允我心安 提交于 2019-11-27 08:33:55
问题 I am using the Action Bar support library (appcompat v7), my app is set to a minimum api of 7, and a target of 21. I have two styles files, a base one, and one targeted at devices api 11+. When running the app on a device running KitKat, it seems that android:actionBarStyle is ignored, leaving the action bar styled as default (@style/Widget.AppCompat.ActionBar.Solid), instead of applying the given background. But if I remove my v11 styles/comment them out, KitKat listens to the actionBarStyle

What wrong with my Style? cannot resolve symbol Theme.AppCompat.Light.NoActionBar

半腔热情 提交于 2019-11-27 08:10:18
问题 Currently, my styles.xml file show something not properly. Theme.AppCompat.Light.NoActionBar cannot be resolve. I have restart android studio but it still not work. I tried Invalidate Caches/Restart , but it not work. It doesn't make my app crash, but why It occurs. Look below image: This is my build.gradle file import org.apache.tools.ant.taskdefs.condition.Os apply plugin: 'com.android.application' apply plugin: 'com.google.gms.google-services' android { compileSdkVersion 23

Changing NumberPicker divider color

旧城冷巷雨未停 提交于 2019-11-27 07:34:38
On recent android versions, number pickers use a blue divider when drawn (cf. image below). I would like to change this color. Is there a working solution? or perhaps a library that package an updated version of NumberPicker that allows customizing the divider color? I have tried android-numberpicker but I get an error (see below) at runtime due to some code from the library that tries to access to a resource id that does not exist. android.content.res.Resources$NotFoundException: Resource ID #0x0 at android.content.res.Resources.getValue(Resources.java:1123) at android.content.res.Resources

How to set Toolbar text and back arrow color

試著忘記壹切 提交于 2019-11-27 06:02:44
Toolbar background is dark color, I want text and back arrow to be white. I tried following, but it doesnt work. <style name="Theme.MyTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="colorPrimary">@color/blue</item> <item name="colorPrimaryDark">@color/blue_darker</item> <item name="colorAccent">@color/purple</item> <!-- item name="android:textColorPrimary">@color/white</item--> // I don't want to set this, changes everywhere. <item name="android:textColorSecondary">@color/white</item> <item name="android:toolbarStyle">@style/AppTheme.ToolbarStyle</item> <item name="toolbarStyle"

How to use Percentage for android layout?

杀马特。学长 韩版系。学妹 提交于 2019-11-27 04:02:22
How can we use percentage values for android view elements? something like this <TextView android:id="@+id/" android:layout_width="75%" android:layout_height="50%"/> Aron UPDATE 2018: PercentRelativeLayout and PercentFrameLayout are deprecated. Consider using ConstraintLayout Old Answer: So far Android Support library has limited on where to use this: with RelativeLayout android.support.percent.PercentRelativeLayout with FrameLayout android.support.percent.PercentFrameLayout How to use it? Well, first make sure to include the dependency at build.grade(Module: app) in your android app.

Action Bar menu item text color

泪湿孤枕 提交于 2019-11-27 03:19:30
How to change text color of menu item title. I tried to change it as below <style name="Theme.Kanku.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title"> <item name="android:textColor">@color/white</item> </style> But it change color only of Action Bar title text, but not menu item text. Try something like this : <style name="ThemeName" parent="@style/Theme.Sherlock.Light"> <item name="actionMenuTextColor">@color/white</item> <item name="android:actionMenuTextColor">@color/white</item> </style> b00n12 I tried several things but nothing worked for me.