[英]actionbar tab indicator is NOT applying custom styles
I have this issue with a viewpager with actionbar tabs, basically I'm not able to apply any of my custom styles to the tabs, this is what I have 我有一个带有动作栏标签的viewpager这个问题,基本上我无法将任何自定义样式应用于标签,这就是我所拥有的
ok so this is using the default tabbed activity that comes with android studio 1.1 here is a list of characteristics I'm have 好的,所以这是使用android studio 1.1随附的默认选项卡式活动的,这里是我拥有的特征列表
MainActivity 主要活动
public class MainActivity extends ActionBarActivity implements ActionBar.TabListener {
SectionsPagerAdapter mSectionsPagerAdapter;
ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
actionBar.setSelectedNavigationItem(position);
}
});
for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
actionBar.addTab(
actionBar.newTab()
activity_main.xml activity_main.xml
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/pager"
android:layout_width="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity" />
I have my custom styles inside the styles.xml and and I have applied them in the manifest 我在styles.xml中有我的自定义样式,并且已将它们应用到清单中
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.CustomTheme" >
This is a small part of my styles that I know is trying to change to a red color indicator 这是我知道要更改为红色指示器的样式的一小部分
<style name="ActionBarTabStyle.Aeroman" parent="@style/Widget.AppCompat.ActionBar.TabView">
<item name="android:background">@drawable/tab_indicator_ab_customTheme</item>
</style>
which is using a red indicator color 使用红色指示器颜色
All looks good to me but as u can see in the screenshot is juts ignoring those styles, I know some of the styles in the styles files are been applied, because for example I have a Theme.AppCompat.Light.DarkActionBar as the parent and if I change it to Theme.AppCompat.Light, the actionBar turns gray, so is working that part, the weird thing for me is that the tab indicator is green which I think it should be blue right? 所有这些对我来说看起来都很不错,但是正如您在屏幕快照中看到的那样,突出显示忽略了这些样式,我知道样式文件中的某些样式已应用,因为例如,我有一个Theme.AppCompat.Light.DarkActionBar作为父项,如果我将其更改为Theme.AppCompat.Light,则ActionBar会变为灰色,因此该部分是否正常工作,对我来说很奇怪的是,选项卡指示器为绿色,我认为应该为蓝色,对吗? and is very thin by default. 并且默认情况下非常薄。
I tested in a genymotion emulator using Nexus 4 with API 16 and in a real device using Nexus 5 with android 5.0.1 我在使用Nexus 4和API 16的genymotion模拟器中以及在使用Nexus 5和android 5.0.1的真实设备中进行了测试
Please help understand this, I pulling my hair here, thanks for any help 请帮助理解这一点,我在这里拉头发,谢谢您的帮助
使用不带android:
前缀的appcompat属性名称,即:
<item name="actionBarTabStyle">@style/ActionBarTabStyle.YourProject</item>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.