参见随附的屏幕截图。我的“上一页”和“下一页”图标的颜色代码为#FFFFFF,比“Up”和“Overflow”的系统图标更暗。
这是一个问题,因为它会导致某些用户认为按钮被禁用。
我在AppBarLayout上的主题是ThemeOverlay.AppCompat.Dark.ActionBar,而工具栏上的主题是ThemeOverlay.AppCompat.Light,如果重要的话。我正在使用appcompat-v7:23.0.1。
这是布局XML ...
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
...以及我的活动代码的相关部分。
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home_activity);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
adapter = new HomePagerAdapter(getFragmentManager(), this);
viewPager.setAdapter(adapter);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabLayout);
tabLayout.setupWithViewPager(viewPager);
tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
}
@Override
protected void onResume() {
super.onResume();
if (forms == null) {
forms = getConfiguredForms();
}
}
@Override
protected void onStart() {
super.onStart();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.home_activity_actions, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Intent intent;
switch (item.getItemId()) {
case R.id.uploadButton:
intent = new Intent(HomeActivity.this, UploadActivity.class);
startActivity(intent);
return true;
case R.id.settingsButton:
intent = new Intent(HomeActivity.this, SettingsActivity.class);
startActivity(intent);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
这是选项菜单的XML。它们是由片段添加的。
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/firstButton"
android:icon="@drawable/first_white"
android:title="@string/first_action"
app:showAsAction="ifRoom" />
<item
android:id="@+id/previousButton"
android:icon="@drawable/previous_white"
app:showAsAction="always"
android:title="@string/previous_action" />
<item
android:id="@+id/nextButton"
android:icon="@drawable/next_white"
app:showAsAction="always"
android:title="@string/next_action" />
<item
android:id="@+id/lastButton"
android:icon="@drawable/last_white"
app:showAsAction="ifRoom"
android:title="@string/last_action" />
<item
android:id="@+id/resetButton"
android:icon="@drawable/reset_white"
app:showAsAction="never"
android:title="@string/reset_action" />
</menu>
答案 0 :(得分:1)
在 styles.xml
中,将以下属性添加到样式中以隐藏默认的ActionBar:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>