android-theme

Set a theme on a View programmatically on Android 5.0 Lollipop

感情迁移 提交于 2019-12-04 11:40:16
Android 5.0 Lollipop added the ability to set a theme for different views (not just the Activity). android:theme="@style/MyAwesomeTheme" Is there a way to set the theme on a view dynamically? android:theme changes specific attributes specified in the theme resource. You could instantiate specific view using any overloaded constructor, like View(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) . which basically is what inflater does. For example v7.widget.Toolbar tries to create themed context out of resource android:theme right in the super call of the constructor, which

How to add custom item in android Theme declaration?

末鹿安然 提交于 2019-12-04 11:25:33
问题 I'm having few custom themes in my styles.xml Now whenever the activity takes the theme, it uses the colorPrimary , colorPrimaryDark and colorAccent values. For my layout's background I'm using ?attr/colorAccent , so it can pick the background color based on the selected theme. If I use any of the above values it works fine. But I want to define a custom item value for my background color. I tried like this below but it didn't worked. any ideas to make it work ? My custom theme with custom

Changing default text colour and still showing disabled menu items in different colour

浪子不回头ぞ 提交于 2019-12-04 10:56:23
With Theme.Holo.Light as the base theme, a designer noticed that the default text colour is not black, but a dark grey ( #505050 ). We'd like to change it to black. Looking for a simple way to change the default to black everywhere in the app, I found that this works: <resources> <style name="MyAppTheme" parent="android:Theme.Holo.Light"> <item name="android:textColor">@android:color/black</item> </style> </resources> Now, problem is , that also changes the colour of disabled items in Action Bar's overflow menu. How to override default text colour while still having disabled menu items look

Change and apply theme at runtime in Android [duplicate]

会有一股神秘感。 提交于 2019-12-04 09:25:13
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: How to change current Theme at runtime in Android I have an Android application where I allow users to switch between themes at runtime. Switching a theme is easy but the theme isn't applied until the activity is recreated. I found a way to apply the theme to current activity but if the user presses back button previous screens still have the old theme. How can I change theme for those activities? Example of app

Style inheritance of extended Widget

佐手、 提交于 2019-12-04 08:57:34
In my project (Target API 21 with AppCompat support), I need to extend the EditText class. My problem is MyEditText class does not inherit EditText style customized with: <style name="AppTheme" parent="@style/Theme.AppCompat.Light.NoActionBar" > <item name="colorPrimary">@color/primary</item> <item name="colorControlNormal">@color/grey_light</item> <item name="colorControlActivated">@color/primary</item> <item name="colorControlHighlight">@color/primary</item> </style> with @color/primary green Screenshot: line 1: EditText focused line 2: EditText not focused (enabled) line 3: MyEditText not

TextInputLayout: Different color for hint label when not focused

帅比萌擦擦* 提交于 2019-12-04 08:28:39
问题 What I want to do: When using an EditText embedded in a TextInputLayout I want to ... Set the Color of the label to GREEN when it's de-focused and floating above the EditText because the user has already entered some value Set the Color of the label to RED when it's de-focused and located inside the EditText, because the user has not yet entered a value I do not want to change the hint text color of all my EditTexts to RED, but only when they're wrapped in a TextInputLayout (I don't need a

Change Theme Color at Runtime in Android [duplicate]

陌路散爱 提交于 2019-12-04 08:06:13
This question already has an answer here: Set theme color dynamically 5 answers Theme colors can be changed if multiple themes added in app and can be switched at run time easily. Other way is to change the color of actiobar, textview etc one by one of all the object. This way is very long and take lots of code. Simple way i found is to change colors declare in colors.xml file but i could not find a way programmatically or third party library to do that. Is there a way to do this. My Colors XML File: <?xml version="1.0" encoding="utf-8"?> <resources> <color name="colorPrimary">#ea1e63</color>

What is difference among styles.xml and themes.xml

ぐ巨炮叔叔 提交于 2019-12-04 07:47:43
问题 May I know what is the difference between styles.xml and themes.xml ? To me, they just look same as both XML are in the same format. <style name="... <item name="... So, in my app which provide customization coloring, size, drawable, ... do I need both styles.xml and themes.xml as well? How should I decide which XML to put in which file? 回答1: Out of the whole page of the Styles and Themes. You may be looking for this line. When you apply a style to a single View in the layout, the properties

Android: change width of overflow menu

十年热恋 提交于 2019-12-04 07:14:08
Currently I have an overflow menu which has default width: What I want is: I have tried changing the theme this way: <style name="MyWorkspaceDetailTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar"> <item name="android:popupMenuStyle">@style/MyPopupMenu</item> </style> <style name="MyPopupMenu" parent="@android:style/Widget.Holo.ListPopupWindow"> <item name="android:dropDownWidth">30dp</item> </style> but didn't got any success. Please can anyone help. I was follwing this[ http://keepsafe.github.io/2014/11/19/building-a-custom-overflow-menu.html] tutorial but it did not mention way

Android : AccountPicker set Light Theme

*爱你&永不变心* 提交于 2019-12-04 03:52:47
Is it possible to set the theme of picker dialog ? import com.google.android.gms.common.AccountPicker; .... String[] accountTypes = new String[]{"com.google"}; Intent intent = AccountPicker.newChooseAccountIntent(null, null, accountTypes, false, null, null, null, null); activity.startActivityForResult(intent, REQUEST_CODE_PICK_ACCOUNT); My base app theme is android:Theme.Light but that dialog is dark. Thanks. If you wish to change the theme of the dialog, you should change the newChooseAccountIntent to zza and add two integer arguments. The first one is for overriding the theme and setting it