如何更改文字大小,动作条下拉列表 - 与动作条福尔摩斯福尔摩斯、动作、文字大小、如何更改

2023-09-12 02:22:37 作者:仅剩旳温纯、

我试图改变字体大小的下拉列表中使用的ActionBar福尔摩斯4.0。

I am trying to change the font size in a drop down list that uses Actionbar Sherlock 4.0.

我从[https://github.com/JakeWharton/ActionBarSherlock/issues/401]看到,你可以使用一个主题改变动作条标签文本大小如下:

I see from [https://github.com/JakeWharton/ActionBarSherlock/issues/401] that you can change the Actionbar tab text size using a theme as follows:

<style name="Theme.MyTheme" parent="Theme.Sherlock">
    <item name="android:actionBarTabTextStyle">@style/Widget.MyTabText</item>
    <item name="actionBarTabTextStyle">@style/Widget.MyTabText</item>
</style>

<style name="Widget.MyTabText" parent="Widget.Sherlock.ActionBar.TabText">
    <item name="android:textSize">14sp</item>
</style>

但我没能找到如何更改文字大小在下拉列表中(也就是说,无论是头部,以及个人的下拉列表中的项目)。

But I've not been able to find how to change the text size in a drop down list (i.e., both the header, and the individual drop down list items).

任何线索?谢谢你。

推荐答案

我已经研究过的ActionBar福尔摩斯的来源,spiner文本的主题使用spinnerItemStyle / actionDropDownStyle但改变没有得到效果 然而,它的工作原理来定义你的自定义布局在spinerAdapter象下面这样:

I've looked into the source of Actionbar Sherlock, the theme of the spiner text uses spinnerItemStyle/actionDropDownStyle but changing that get no effect However, it works to define your custom layout in the spinerAdapter like below :

    Context context = getSupportActionBar().getThemedContext();
    ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(
            context, R.array.orderstatus, R.layout.spinner_item);
    list.setDropDownViewResource(R.layout.spinner_dropdown_item);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    getSupportActionBar().setListNavigationCallbacks(list, this);

在那里同样的布局文件:

where the layout file like:

    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    style="@style/ActionBar.TitleText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ellipsize="marquee"
    android:singleLine="true" />