Change CalendarView style

In my project I defined the attribute “android:calendarViewStyle” in my theme. <style name=”Theme.Custom” parent=”@android:Theme”> <item name=”android:calendarViewStyle”>@style/Widget.CalendarView.Custom</item> </style> <style name=”Widget.CalendarView.Custom” parent=”android:Widget.CalendarView”> <item name=”android:focusedMonthDateColor”>@color/cs_textcolor</item> <item name=”android:weekNumberColor”>@color/red</item> <item name=”android:weekDayTextAppearance”>@style/TextAppearance.Medium</item> <item name=”android:dateTextAppearance”>@style/TextAppearance.Medium</item> </style> All styles possibilities are: @attr ref android.R.styleable#CalendarView_showWeekNumber @attr ref android.R.styleable#CalendarView_firstDayOfWeek @attr ref android.R.styleable#CalendarView_minDate @attr ref android.R.styleable#CalendarView_maxDate @attr ref android.R.styleable#CalendarView_shownWeekCount @attr ref android.R.styleable#CalendarView_selectedWeekBackgroundColor @attr ref android.R.styleable#CalendarView_focusedMonthDateColor @attr … Read more

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

You can achieve it through code. Obtain the back arrow drawable, modify its color with a filter, and set it as back button. final Drawable upArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha); upArrow.setColorFilter(getResources().getColor(R.color.grey), PorterDuff.Mode.SRC_ATOP); getSupportActionBar().setHomeAsUpIndicator(upArrow); Revision 1: Starting from API 23 (Marshmallow) the drawable resource abc_ic_ab_back_mtrl_am_alpha is changed to abc_ic_ab_back_material. EDIT: You can use this code to achieve the … Read more

How to custom switch button?

However, I might not be taking the best approach, but this is how I have created some Switch like UIs in few of my apps. Here is the code – <RadioGroup android:checkedButton=”@+id/offer” android:id=”@+id/toggle” android:layout_width=”match_parent” android:layout_height=”30dp” android:layout_marginBottom=”@dimen/margin_medium” android:layout_marginLeft=”50dp” android:layout_marginRight=”50dp” android:layout_marginTop=”@dimen/margin_medium” android:background=”@drawable/pink_out_line” android:orientation=”horizontal”> <RadioButton android:layout_marginTop=”1dp” android:layout_marginBottom=”1dp” android:layout_marginLeft=”1dp” android:id=”@+id/search” android:background=”@drawable/toggle_widget_background” android:layout_width=”0dp” android:layout_height=”match_parent” android:layout_weight=”1″ android:button=”@null” android:gravity=”center” android:text=”Search” android:textColor=”@color/white” /> … 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.

How can I style an Android Switch?

You can define the drawables that are used for the background, and the switcher part like this: <Switch android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:thumb=”@drawable/switch_thumb” android:track=”@drawable/switch_bg” /> Now you need to create a selector that defines the different states for the switcher drawable. Here the copies from the Android sources: <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:state_enabled=”false” android:drawable=”@drawable/switch_thumb_disabled_holo_light” /> <item android:state_pressed=”true” android:drawable=”@drawable/switch_thumb_pressed_holo_light” … 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>

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