I wanted to place the spinner in the action bar, as in the Gmail application. So I created the following layout.
<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView android:id="@+id/spinner_list_item_selected_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textStyle="bold"
android:gravity="center"
android:text="Sales" />
<TextView android:id="@+id/spinner_list_item_selected_text" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textStyle="bold"
android:gravity="center"
android:text="" />
</LinearLayout>
This counter is then loaded into the header line using the following code:
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
getActionBar().setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener);
It works as expected, except in landscape mode the text is not suitable. In Gmail, the font size is reduced. Is there a way to automatically adjust the font size based on orientation?




source
share