问题描述
我用微调的导航在我的动作条。一切正常,除了造型。
I use Spinner navigation in my actionbar. Everything works fine except styling.
我想微调导航看起来像有一个标题和副标题的动作条:
I would like the spinner nav to look like an actionbar which has a title and a subtitle:
但是,如果我用微调导航,我要设置标题和副标题为空字符串,并提供自己的微调视图。这是我做的,但它看起来像这样:
But if I use spinner nav, I have to set the title and subtitle to empty string and provide my own spinner view. Which I do, but it looks like this:
问:什么是风格,使微调看起来与上述相同的图片
请注意:我试着设置TextViews textAppearance为安卓textAppearance =@安卓风格/ TextAppearance.Medium
和安卓textAppearance = @android:款式/ TextAppearance.Small
分别,但没有奏效。
Note: I tried setting TextViews textAppearance to android:textAppearance="@android:style/TextAppearance.Medium"
and android:textAppearance="@android:style/TextAppearance.Small"
respectively, but it didn't work.
我使用本机动作条,没有ABS。
I use native Actionbar, not ABS.
推荐答案
这些项目的hieght在 /中所定义; Android的SDK> /平台/ Android为15 /数据/ RES /值/dimens.xml
文件,像这样的:
The hieght of these items are defined in /<android-sdk>/platforms/android-15/data/res/values/dimens.xml
file, like this:
<dimen name="action_bar_default_height">48dip</dimen>
<dimen name="action_bar_title_text_size">18dp</dimen>
<dimen name="action_bar_subtitle_text_size">14dp</dimen>
<dimen name="action_bar_subtitle_top_margin">-3dp</dimen>
<dimen name="action_bar_subtitle_bottom_margin">5dip</dimen>
(详情点击这里:http://stackoverflow.com/a/11686495/989029)
您应该重新定义所需的值(请注意,这些值是不同的方向不同,所以你需要几个文件也一样)在你的资源文件夹,并利用它们是这样的:
You should redefine required values (Note that these values are different for various orientations, so you need several files as well) in your res folder and use them like this:
actionbar_spinner_item.xml:
actionbar_spinner_item.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical"
android:paddingLeft="5dp"
android:paddingRight="5dp">
<TextView
android:id="@+id/action_bar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:text="@string/title_activity_main"
android:textSize="@dimen/action_bar_title_text_size"
android:textColor="@android:color/primary_text_dark"
android:textStyle="bold" />
<TextView
android:id="@android:id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/action_bar_subtitle_top_margin"
android:ellipsize="end"
android:singleLine="true"
android:textColor="@android:color/primary_text_dark"
android:textSize="@dimen/action_bar_subtitle_text_size" />
</LinearLayout>
我在getView()方法的自定义ArrayAdapter使用此布局。从你的截图我假设你知道的细节。
I use this layout in a custom ArrayAdapter in getView() method. From your screenshots I assume you know the details.
这一切提供了以下的结果,看起来如预期在我测试过的所有设备。
All this gives the following result, that looks as expected on all devices I've tested.
这篇关于造型动作条微调导航看起来像它的标题和副标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!