How to change size of title’s text on Action Bar?

Actually, you can do what you want to customize the ActionBar. It must be done through the Theme. You can do something like this : <style name=”Theme.YourTheme” parent=”android:style/Theme”> <item name=”android:actionBarStyle”>@style/Theme.YourTheme.Styled.ActionBar</item> </style> <style name=”Theme.YourTheme.Styled.ActionBar”> <item name=”android:titleTextStyle”>@style/Theme.Viadeo.Styled.YourTheme.TitleTextStyle</item> </style> <style name=”Theme.YourTheme.Styled.ActionBar.TitleTextStyle” parent=”@android:style/Widget.TextView”> <item name=”android:textSize”>12sp</item> </style>

How to get text on an ActionBar Icon?

Here is some example code that worked for me. 1: Create a layout for your badge menu item. <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”48dp” android:layout_height=”fill_parent” android:layout_gravity=”right” > <!– Menu Item Image –> <ImageView android:layout_width=”48dp” android:layout_height=”fill_parent” android:clickable=”true” android:src=”https://stackoverflow.com/questions/13288989/@drawable/bkg_actionbar_notify_off” /> <!– Badge Count –> <TextView android:id=”@+id/actionbar_notifcation_textview” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_alignParentRight=”true” android:padding=”@dimen/padding_small” android:text=”99″ android:textColor=”@color/holo_orange_dark” /> </RelativeLayout> 2: Create a menu item in … Read more

How to align title at center of ActionBar in default theme(Theme.Holo.Light)

You can create a custom layout and apply it to the actionBar. To do so, follow those 2 simple steps: Java Code getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); getSupportActionBar().setCustomView(R.layout.actionbar); Where R.layout.actionbar is the following layout. XML <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_gravity=”center” android:orientation=”vertical”> <TextView android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_gravity=”center” android:id=”@+id/action_bar_title” android:text=”YOUR ACTIVITY TITLE” android:textColor=”#ffffff” android:textSize=”24sp” /> </LinearLayout> It can be … Read more

AppCompat v7 Toolbar onOptionsItemSelected not called

I know this question has been answered but I found the real cause of the problem after 2 days of frustration. Take a look at the ActionBarDrawerToggle documentation: https://developer.android.com/reference/android/support/v7/app/ActionBarDrawerToggle.html Notice the two constructors there. My mistake was that I was using the second constructor that was taking a toolbar as a parameter. It took me … Read more

Android : Change entire app layout directions programmatically

You can use this piece of code while your application’s minSdk >= 17. I used fa for Farsi, you can use other rtl language. Configuration configuration = getResources().getConfiguration(); configuration.setLayoutDirection(new Locale(“fa”)); getResources().updateConfiguration(configuration, getResources().getDisplayMetrics());