android - Logo disappear from toolbar after while -
when install app seems ok. when return after moment there no logo in toolbar. there black. ok in android 4.4, galaxy s4 upgraded android 5.0.1 , there bug in app. don't know why please?
v21\styles.xml
<style name="apptheme" parent="theme.appcompat.light.noactionbar"> <!-- customize 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>
and same in drawer header (toolbar or drawer header black ... not both)
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>
nothing special in 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);
i found solution. black shape displays in action bar because 1 big-size logo.png in folder "drawable". logo must in drawable-mdpi/hdpi/etc. in equal sizes (48dp/56dp height, depends on android version). don't know why android 5.0.1 on galaxy s4 doesn't downsize picture correct emulators or real 4.4.2 device. seems ok.
Comments
Post a Comment