Set style for TextView programmatically

I do not believe you can set the style programatically. To get around this you can create a template layout xml file with the style assigned, for example in res/layout create tvtemplate.xml as with the following content: <?xml version=”1.0″ encoding=”utf-8″?> <TextView xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:text=”This is a template” style=”@style/my_style” /> then inflate this to instantiate … Read more

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

As per documentation – “You can control the behaviors and visibility of the action bar with the ActionBar APIs, which were added in Android 3.0 (API level 11).” So, ActionBar will not work for your target environment which is at API level 10 (Android 2.3.3). Just in case, if you target for minimum API level … Read more

Changing EditText bottom line color with appcompat v7

Finally, I have found a solution. It simply consists of overriding the value for colorControlActivated, colorControlHighlight and colorControlNormal in your app theme definition and not your edittext style. Then, think to use this theme for whatever activity you desire. Below is an example: <style name=”Theme.App.Base” parent=”Theme.AppCompat.Light.DarkActionBar”> <item name=”colorControlNormal”>#c5c5c5</item> <item name=”colorControlActivated”>@color/accent</item> <item name=”colorControlHighlight”>@color/accent</item> </style>

Android toolbar center title and custom font

To use a custom title in your Toolbar all you need to do is remember is that Toolbar is just a fancy ViewGroup so you can add a custom title like so: <android.support.v7.widget.Toolbar android:id=”@+id/toolbar_top” android:layout_height=”wrap_content” android:layout_width=”match_parent” android:minHeight=”?android:attr/actionBarSize” android:background=”@color/action_bar_bkgnd” app:theme=”@style/ToolBarTheme” > <TextView android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”Toolbar Title” android:layout_gravity=”center” android:id=”@+id/toolbar_title” /> </android.support.v7.widget.Toolbar> This means that you can style … Read more

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

I don’t have idea why it is happening but there 3 trivial attempts to make: Use android:textAllCaps=”false” in your layout-v21 Programmatically change the transformation method of the button. mButton.setTransformationMethod(null); Check your style for Allcaps Note: public void setAllCaps(boolean allCaps), android:textAllCaps are available from API version 14.