【发布时间】:2015-03-01 23:51:57
【问题描述】:
我正在尝试将 NavigationDrawer 与 appcompat 和操作栏一起使用。通过从左侧滑动或触摸操作栏,我的 NavDrawer 正在工作。
在the navigation drawer sample app,操作栏上的home icon 显示在与3-stripes-drawable 相同的“容器”中,表示存在侧边菜单。但是在我的应用程序中,home icon 显示在这个“容器”之外......我正在上传图片以更好地解释正在发生的事情。此外,home icon 看起来比 google 的示例应用程序大得多,尽管尺寸相同(xhdpi 为 96x96)。 ic_drawer drawable 在两个应用程序中是相同的。
我不想使用与应用启动器图标相同的可绘制对象。
在两个屏幕截图中,我都在触摸操作栏以打开导航抽屉(请参见突出显示的方块):
我的清单:
<application
android:allowBackup="true"
android:icon="@mipmap/icon"
android:label="@string/app_name"
android:theme="@style/MyAppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
我的风格:
<resources>
<style name="MyAppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar">
<item name="titleTextStyle">@style/TitleTextStyle</item>
<item name="background">@color/black</item>
<item name="logo">@drawable/actionbar_logo</item>
<item name="displayOptions">useLogo|showHome|showTitle</item>
</style>
<style name="TitleTextStyle"
parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#FFFFFF</item>
</style>
</resources>
我的 MainActivity 的 onCreate:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerToggle = new android.support.v4.app.ActionBarDrawerToggle(
this, mDrawerLayout, R.drawable.ic_drawer, R.string.app_name, R.string.app_name) {
public void onDrawerClosed(View view) {
}
public void onDrawerOpened(View drawerView) {
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
}
感谢您对此的任何帮助。
【问题讨论】:
-
你在使用 app compat 21 吗?
-
@GabrieleMariotti 是的,com.android.support:appcompat-v7:21.0.3
标签: android android-actionbar navigation-drawer android-appcompat