API 21 之後預設移除 app icon。
android.support.v7.widget.Toolbar
The use of application icon plus title as a standard layout is discouraged on API 21 devices and newer.
android.support.v7.app.ActionBar
When using the Material themes (default in API 21 or newer) the navigation button (formerly "Home") takes over the space previously occupied by the application icon.
設定 app icon :
protected void onCreate(Bundle savedInstanceState) { ActionBar actionBar = getSupportActionBar(); actionBar.setLogo(R.drawable.ic_laucher); actionBar.setDisplayUseLogoEnabled(true); actionBar.setDisplayShowHomeEnabled(true); }
⚠ icon 需要在 drawable 目錄,不能使用 mipmap。
⚠ 3 個方法都要寫。
參考資料:StackOverflow: The application icon does not show on action bar
Android Studio 1.3 compileSdkVersion 22 buildToolsVersion "23.0.0 rc3" com.android.support:appcompat-v7:22.2.+
沒有留言:
張貼留言