动作条在水平视图选项卡样式 [英] ActionBar tab styles in horizontal view

查看:111
本文介绍了动作条在水平视图选项卡样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用手机或在纵向模式片剂,选项卡显示constains的标志和菜单项的动作条下。在横向模式下平板电脑,他们显示内嵌的标志和菜单项。在这种结构中seleced选项卡下的下划线丢失

When using a phone or a tablet in portrait mode, tabs are shown under the ActionBar that constains the logo and menu items. On tablets in horizontal mode they are shown inline with the logo and menu items. In this configuration the underscore under the seleced tab is lost.

什么风格的控制呢?在纵向模式我想使用一个不同的选择的样式比在横向模式时,标签与标志和菜单显示在线。

What style controls this? In portrait mode I want to use a different selected style than in landscape mode when tabs are shown inline with the logo and menu.

我的主题有它的父设置为 Theme.AppCompat.Light 。在这我有

My theme has it's parent set to Theme.AppCompat.Light. Under it I have

<item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Silence</item>
<item name="android:actionBarStyle">@style/ActionBar.Solid.Silence</item>

安卓actionBarTabStyle 安卓背景值设置为一个可绘制的是

android:actionBarTabStyle has android:background value set to a drawable that is

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- Non focused states -->
    <item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@android:color/transparent" />
    <item android:state_focused="false" android:state_selected="true"  android:state_pressed="false" android:drawable="@drawable/tab_selected_silence" />

    <!-- Focused states -->
    <item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected_focused_silence" />
    <item android:state_focused="true" android:state_selected="true"  android:state_pressed="false" android:drawable="@drawable/tab_selected_focused_silence" />

    <!-- Pressed -->
    <!--    Non focused states -->
    <item android:state_focused="false" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed_silence" />
    <item android:state_focused="false" android:state_selected="true"  android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_silence" />

    <!--    Focused states -->
    <item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed_silence" />
    <item android:state_focused="true" android:state_selected="true"  android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_silence" />
</selector>

我看到这些 state_selected 值。被设置为绘制这些图像是不同的颜色,动作条的背景,所以它不只是我看不到他们在相同颜色的背景之上。

I see these state_selected values. The image that is set as the drawable for these is different color than the ActionBar background, so it's not just that I can't see them on top of the same colored background.

风格的 actionBarStyle 包含

<item name="android:background">@drawable/ab_solid_silence</item>
<item name="android:backgroundStacked">@drawable/ab_stacked_solid_silence</item>
<item name="android:backgroundSplit">@drawable/ab_bottom_solid_silence</item>
<item name="android:progressBarStyle">@style/ProgressBar.Silence</item>

这三个第一的是图像和 progressBarStyle 包含一些风格了,但他们是无关紧要的。

The three first ones are images and the progressBarStyle contains some styles too, but they are irrelevant.

推荐答案

您应该有兴趣ActionBarTabStyle。

You should be interested in ActionBarTabStyle.

要使用不同的图像,内嵌标签,你可以认为它重新presents风景模式和创建一个自定义选择为风景模式。

To use different images for inline tabs you can assume that it represents landscape mode and create a custom selector for landscape mode.

如果你想一套完整的方案来尝试,看看这个 http://jgilfelt.github.io/android-actionbarstylegenerator 下载ZIP,用自己的PNG文件替换生成的图像,并添加风格在你的项目。

If you want complete set of options to try out, check this out http://jgilfelt.github.io/android-actionbarstylegenerator Download the zip, replace the generated images with your own png files and add the style in your project.

这篇关于动作条在水平视图选项卡样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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