How to change action bar size
Use height
attribute, actionBarSize
if for something else.
<item name="android:height">@dimen/bar_height</item>
Explanantion:
From source code of ActionBar:
mContentHeight = a.getLayoutDimension(R.styleable.ActionBar_height, 0);
We can see that R.styleable.ActionBar_height
is being used for height. Stylable
property names are generated as component_attribute
(If you have ever used a custom stylable
view, you'd have notice this). Hence, Actionbar
is the name of component and height
is the name of the attribute to use. Since this is a system attribute, hence defined under android
namespace.
Update Dec-2014:
AppCompat library is now provided to extend support for latest ActionBar (or Toolbar) and theme support to old android versions. Below is an example of such an application theme /res/values/styles.xml
:
<resources>
<!-- Application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Main theme colors -->
<!-- your app branding color for the app bar -->
<item name="colorPrimary">@color/primary</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="colorPrimaryDark">@color/primary_dark</item>
<!-- theme UI controls like checkboxes and text fields -->
<!-- native widgets will now be "tinted" with accent color -->
<item name="colorAccent">@color/accent</item>
<!--Action bar style-->
<item name="android:actionBarStyle">@style/AppTheme.ActionBar</item>
<item name="actionBarStyle">@style/AppTheme.ActionBar</item>
</style>
<style name="AppTheme.ActionBar" parent="Widget.AppCompat.Light.ActionBar">
<item name="android:titleTextStyle">@style/AppTheme.ActionBar.TitleText</item>
<item name="titleTextStyle">@style/AppTheme.ActionBar.TitleText</item>
<item name="android:height">@dimen/bar_height</item>
<item name="height">@dimen/bar_height</item>
</style>
<style name="AppTheme.ActionBar.TitleText" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textSize">@dimen/bar_text_size</item>
<item name="android:textColor">@color/bar_text_color</item>
</style>
</resources>
This style can now be set as app theme by using android:theme="@style/AppTheme"
in <application>
tag of the AndroidManifest.xml
.
Note the use of duplicate entries
<item name="android:actionBarStyle">
<item name="actionBarStyle">
The ones without android
namespace are there for supporting both compatibility library and native attributes.Some of these attributes didn't exist under android namespace on older versions and belong to support library.
In some other places, you'll need to use app
namespace (xmlns:app="http://schemas.android.com/apk/res-auto"
), for example app:showAsAction="always"
in menu xml files.
Update Apr 2015
AppCompat Library v22 is also available. Read through the article to know what's new.
How to change the height of action bar in android 4.2.2
To set the height of ActionBar you can create a new file themes.xml in your res/values
folder:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.FixedSize" parent="@android:style/Theme.Holo.Light.DarkActionBar">
<item name="actionBarSize">48dip</item>
<item name="android:actionBarSize">48dip</item>
</style>
</resources>
and set this Theme to your Activity:
android:theme="@style/Theme.FixedSize"
How To Reduce Height of Action Bar in Android Layout
Create the new theme and use this:
How to change action bar size
Or use the Android Developers site: http://developer.android.com/reference/android/app/ActionBar.LayoutParams.html
Related Topics
Static Variable Null When Returning to the App
Why Doesn't Logcat Show Anything in My Android
How to Prevent a Service from Being Killed by Os
How to Do Http Authentication in Android
Android Webview Not Loading an Https Url
Audiorecord Object Not Initializing
Embedding Ads Within Recyclerview
Running the New Intel Emulator for Android
Get Android API Level of Phone Currently Running My Application
How to Change Progressbar's Progress Indicator Color in Android
Is This the Right Way to Clean-Up Fragment Back Stack When Leaving a Deeply Nested Stack
How to Set Up Android Emulator Proxy Settings
How to Copy Text Programmatically in My Android App
Get Current Location of User in Android Without Using Gps or Internet
The APK File Does Not Exist on Disk