自定义动作条选项卡上的Andr​​oid 4.0自定义、卡上、选项、动作

2023-09-12 02:07:37 作者:森芋暖暖

我想对我的动作条自定义选项卡。我只是想对齐选项卡的手机屏幕,并使其伸展为各种屏幕。但我得到的是这样的:

I'm trying to customize Tabs on my ActionBar. I just want to align tabs to phone screen and make it stretchable for various screens. But all I get is this:

在code我使用的主题是这样的:

The code I use for the theme is this:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style name="MyTheme" parent="@android:style/Theme.Holo.Light">
        <item name="android:actionBarTabTextStyle">@style/MyActionBarTabTextStyle</item>
    </style>

    <style name="MyActionBarTabTextStyle" parent="@android:style/Widget.Holo.Light.Tab">
        <item name="android:textSize">14dip</item>
        <item name="android:padding">0dip</item>
    </style>

</resources>

是否有可能只是减少字体和摆脱掉那些蓝色的线?

Is it possible just decrease the font and get rid off those blue lines?

感谢您​​的帮助提前。

P.S:同样的按钮行为怪异。在任何文本(虽然它应该是)......

P.S.: Also the Button acts weird. The is no text (while it should be)...

推荐答案

编辑:使用 ActionBarCompat 在支持库

我建议你用杰克沃顿商学院的 ActionBarSherlock 有两个原因:

I suggest you use Jake Wharton's ActionBarSherlock for two reasons:

ActionBarSherlock是方便使用在所有版本的Andr​​oid操作栏的兼容性库的扩展。这意味着运行您的pre-蜂窝的Andr​​oid版本的应用程序的用户将可以使用动作条导航以及。这是preferable到两个用户(因为动作条是真棒!)和你(因为你不必担心分离的控制流的基于与否的动作条将可用的应用程序,例如,没有pre-蜂窝兼容动作条,你可能会担心创建多个活动 S表示一个屏幕......一个是为使用与动作条,和一个可以在pre-蜂窝设备上运行。

ActionBarSherlock is an extension of the compatibility library that facilitates the use of the action bar across all versions of Android. This means users running your application on pre-HoneyComb versions of Android will be able to use the ActionBar for navigation as well. This is preferable to both the user (since the ActionBar is awesome!) and to you (since you don't have to worry about separating the control flow of your application based on whether or not the ActionBar will be available. For instance, without a pre-HoneyComb compatible ActionBar, you might have to worry about creating multiple Activitys for a single screen... one that is optimized for usage with the ActionBar, and one that can be run on pre-HoneyComb devices.

通过ActionBarSherlock,造型你的动作条是容易的!我可以去详细讨论如何做到这一点,但库已经自带了样品的很多说明如何为您所描述的上述内容。

With ActionBarSherlock, styling your ActionBar is easy! I could go into detail on how to do it, but the library already comes with a LOT of sample code that illustrates how to what you are describing above.

安装/利用图书馆是很容易的,几乎是相​​同的,利用正常的动作条在Android SDK中提供(大多只是叫 getSupportActionBar(),而不是 getActionBar的())。如果你有任何问题,让我知道。

Installing/making use of the library is very easy and is almost identical to making use of the normal ActionBar provided in the Android SDK (mostly just call getSupportActionBar() instead of getActionBar()). If you have any questions, let me know.

P.S。还要注意的是 ActionBarSherlock 提供了所有的ViewPagerExtensions库提供了更多的功能的。我肯定会推荐使用前者优于后者。

p.s. Also note that ActionBarSherlock provides all of the functionalities that the ViewPagerExtensions library provides and more. I would definitely recommend using the former over the latter.

 
精彩推荐