如何自动调整字体大小的基础上定向操作栏微调? [英] How to auto adjust font size in the action bar spinner based on orientation?

查看:121
本文介绍了如何自动调整字体大小的基础上定向操作栏微调?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想把它放到一个微调操作栏中,就像在Gmail应用程序。所以,我创建了下面的布局。

I wanted to place a spinner in the action bar, just like in the Gmail app. 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>

本微调,然后装上的标题栏使用以下code:

This spinner is then loaded on to the title bar using the following code:

getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
getActionBar().setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener);

它正常工作,只是在横向模式下,该文本是不恰当的。在Gmail应用程序,字体大小会减少。 有没有办法自动根据方向调整字体大小?

推荐答案

//你需要使用dimens.xml价值观文件夹

//you need to use dimens.xml in values folder

<!-- Text size for action bar titles -->
    <dimen name="action_bar_title_text_size">18dp</dimen>
    <!-- Text size for action bar subtitles -->
    <dimen name="action_bar_subtitle_text_size">14dp</dimen>
    <!-- Top margin for action bar subtitles -->
    <dimen name="action_bar_subtitle_top_margin">-3dp</dimen>
    <!-- Bottom margin for action bar subtitles -->
    <dimen name="action_bar_subtitle_bottom_margin">5dip</dimen>

创建具有价值,土地多了一个文件夹

create one more folder with values-land

在dimens.xml

in that dimens.xml

 <!-- Text size for action bar titles -->
    <dimen name="action_bar_title_text_size">16dp</dimen>
    <!-- Text size for action bar subtitles -->
    <dimen name="action_bar_subtitle_text_size">12dp</dimen>
    <!-- Top margin for action bar subtitles -->
    <dimen name="action_bar_subtitle_top_margin">-2dp</dimen>
    <!-- Bottom margin for action bar subtitles -->
    <dimen name="action_bar_subtitle_bottom_margin">4dip</dimen>

编号:转到 /&LT; Android的SDK&GT; /平台/ Android为15 /数据/ RES 在这里,你可以发现这个

Ref: go to your /<android-sdk>/platforms/android-15/data/res here you can found this.

这篇关于如何自动调整字体大小的基础上定向操作栏微调?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆