Questions tagged [android-styles]

A style is a collection of properties that specify the look and format for a View or window

From the developer's guide:

A style is a collection of properties that specify the look and format for a View or window. A style can specify properties such as height, padding, font color, font size, background color, and much more. A style is defined in an XML resource that is separate from the XML that specifies the layout.

Styles in Android share a similar philosophy to cascading stylesheets in web design—they allow you to separate the design from the content.

For example, by using a style, you can take this layout XML:

<TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#00FF00" android:typeface="monospace" android:text="@string/hello" />

And turn it into this:

<TextView style="@style/CodeFont" android:text="@string/hello" />
1918 questions
619
votes
28 answers

Set EditText cursor color

I am having this issue where I am using the Android's Holo theme on a tablet project. However, I have a fragment on screen which has a white background. I am adding an EditText component on this fragment. I've tried to override the theme by setting…
dineth
  • 9,822
  • 6
  • 32
  • 39
500
votes
20 answers

Why is my Button text forced to ALL CAPS on Lollipop?

In my app "Tide Now WA" which I recently tested for compatibility using the new Nexus 9 tablet (Lollipop - API 21). It writes some button text. This app writes the text correctly using Android 2.3 and Android 4.0. I.e. mixed capital and lower case…
user1644002
  • 3,211
  • 3
  • 19
  • 21
420
votes
41 answers

Android toolbar center title and custom font

I'm trying to figure out the right way to use a custom font for the toolbar title, and center it in the toolbar (client requirement). At the moment, i'm using the good old ActionBar, and I was setting the title to empty value, and using…
326
votes
25 answers

Changing EditText bottom line color with appcompat v7

I am using appcompat v7 to get the look consistent on Android 5 and less. It works rather well. However I cannot figure out how to change the bottom line color and the accent color for EditTexts. Is it possible? I have tried to define a custom…
Laurent
  • 14,122
  • 13
  • 57
  • 89
302
votes
20 answers

How do I change the background color of the ActionBar of an ActionBarActivity using XML?

Details: I'm extending ActionBarActivity. Eclipse and SDK fully patched as of 2011-11-06. Deployed to Samsung device with Android 2.3.3 Application has…
user77115
  • 5,517
  • 6
  • 37
  • 40
263
votes
13 answers

Set style for TextView programmatically

I'm trying to use the TextView constructor with style like this: TextView myText = new TextView(MyActivity.this, null, R.style.my_style); However, when I do this, the text view does not appear to take the style (I verified the style by setting it…
Ben
  • 16,124
  • 22
  • 77
  • 122
211
votes
25 answers

How to change color of the back arrow in the new material theme?

I've updated my SDK to API 21 and now the back/up icon is a black arrow pointing to the left. I would like it to be grey. How can I do that? In the Play Store, for example, the arrow is white. I've done this to set some styles. I have used…
Ferran Maylinch
  • 10,919
  • 16
  • 85
  • 100
188
votes
6 answers

Custom attributes in styles.xml

I have created a custom widget, and I'm declaring it in layout.xml. I have also added some custom attributes in attr.xml. However, when trying to declare these attributes in a style in styles.xml, it's giving me No resource found that matches the…
Tyler
  • 19,113
  • 19
  • 94
  • 151
182
votes
24 answers

Cannot resolve symbol 'Theme' in styles.xml (Android Studio)

Since today, Android Studio can't find the AppCompat themes in styles.xml, but for example AppCompatActivity in code does get recognized. My Android Studio version is 2.2.2, Build #AI-145.3360264 I already tried upgrading to the latest build tools,…
FLP
  • 2,050
  • 2
  • 14
  • 16
170
votes
11 answers

Android statusbar icons color

I was wondering if it's possible to change the statusbar icons colour (not the statusbar colour, colorPrimaryDark) Let's say I want this statusbar with: @android:color/white and the icons in black, is it…
GuilhE
  • 11,591
  • 16
  • 75
  • 116
151
votes
2 answers

Question mark (?) in XML attributes for Android

Can anyone explain the question mark means in Android XML attributes?
Casebash
  • 114,675
  • 90
  • 247
  • 350
144
votes
2 answers

Using App namespace in style

I am going to give an example to demonstrate the greater point. Imagine my app has a number of FloatingActionButtons. Consequently, I want to create one style and reuse it. So I do the following: