-1
當我安裝我的應用程序時,一切似乎都沒問題。但是當我稍後回來時,我的工具欄中沒有徽標。只有黑色。在Android 4.4中是可以的,但我的Galaxy S4已升級到Android 5.0.1,並且在我的應用程序中有這個錯誤。你不知道爲什麼要嗎?徽標從工具欄中消失後
V21 \ styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/ColorPrimary</item>
<item name="colorPrimaryDark">@color/ColorPrimaryDark</item>
<item name="colorAccent">@color/ColorAccent</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:statusBarColor">@color/ColorPrimaryDark</item>
</style>
toolbar.xml
<android.support.v7.widget.Toolbar 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="?attr/actionBarSize"
android:background="@color/ColorPrimary"
app:titleTextAppearance="@style/ToolbarTitle"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:elevation="@dimen/toolbar_elevation">
<ImageView
android:id="@+id/tool_logo"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:adjustViewBounds="true"
android:contentDescription="@string/img_logo"
android:src="@drawable/logo" />
</android.support.v7.widget.Toolbar>
和相同的是在抽屜報頭(工具欄或抽屜頭有時黑色...不是兩者)
drawer_header.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@color/ColorPrimary">
<ImageView
android:id="@+id/navHead"
android:layout_width="match_parent"
android:layout_height="@dimen/drawer_header_height"
android:adjustViewBounds="true"
android:src="@drawable/logo"
android:contentDescription="@string/img_logo" />
</LinearLayout>
沒有什麼特別的,我MainOverview.java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_list);
mDrawerList = (ListView)findViewById(R.id.navList);
final LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View drawerHeaderView = layoutInflater.inflate(R.layout.drawer_header, null);
mDrawerList.addHeaderView(drawerHeaderView);
toolbar = (Toolbar) findViewById(R.id.tool_bar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
嘗試使用setLogo()和操作欄。 – Harry
謝謝你的建議,但它沒有幫助。 –