Reputation: 461
I'm using api 8+ . This is my code for making the menus :
<item
android:id="@+id/sortDate"
android:orderInCategory="100"
android:title="@string/sortDate"
yourapp:showAsAction="never"/>
<item
android:id="@+id/sortPrice"
android:orderInCategory="100"
android:title="@string/sortPrice"
yourapp:showAsAction="never"/>
it shows me the menus but the text size is very large , I want to use my custom typeface and textsize for menus and also supporting api 8+ .
I've found someways but they work on api 11+
How can I do so ?
thanks
Upvotes: 1
Views: 953
Reputation: 552
You have to use custom style in style.xml file:
<style name="CustomActionBar" parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Menu">
<item name="android:textSize">16dip</item>
Upvotes: 1
Reputation: 887
You can use android support appcompat lib.This code custom action bar component with appcompat.
ActionBar mActionBar = getSupportActionBar();
mActionBar.setDisplayShowHomeEnabled(false);
mActionBar.setDisplayShowTitleEnabled(false);
**mActionBar.setCustomView(R.layout.actionview_main);**
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
View mCustomView = mActionBar.getCustomView();
textViewTitle = (TextView) mCustomView.findViewById(R.id.textView_Title);
ImageView menuImage = (ImageView) mCustomView.findViewById(R.id.imageView_menu);
ImageView userImageView = (ImageView) mCustomView.findViewById(R.id.imageView_user);
You create action view xml file then actionbar setcustomview your xml file.
Upvotes: 0
Reputation: 5786
Try this -
Define text size in dimens in res/values/dimens.xml
-
<dimen name="actionbar_textsize">TextSize</dimen>
Then add this code in res/values/styles
-
<style name="MyTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Medium">
<item name="android:textSize">@dimen/actionbar_textsize</item>
</style>
Then -
<item name="titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
<item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
Upvotes: 2