在纵向模式下使用手机或平板电脑时,选项卡会显示在包含徽标和菜单项的 ActionBar 下方。在水平模式的平板电脑上,它们与徽标和菜单项一起显示。在此配置中,选定选项卡下的下划线将丢失。
什么风格控制这个?在肖像模式下,我想在徽标和菜单内线显示标签时使用与景观模式不同的选择样式。
我的主题将它的父级设置为Theme.AppCompat.Light
. 在它下面我有
<item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Silence</item>
<item name="android:actionBarStyle">@style/ActionBar.Solid.Silence</item>
android:actionBarTabStyle
将android:background
值设置为可绘制对象
<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
价值观。为这些设置为可绘制的图像与 ActionBar 背景颜色不同,所以不仅仅是我在相同颜色的背景上看不到它们。
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
包含一些样式,但它们无关紧要。