1
A
回答
1
一号改变杆的工具栏然后
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
三号 mainfest->变化图标
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
+0
这部分帮助我,现在有一个主页按钮,当我移动到另一个布局。但它仍然不显示图标。 @Cgx –
1
创建toolbar_actionbar.xml如下:
<?xml version="1.0" encoding="utf-8"?>
<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="56dp"
android:background="@color/colorPrimary"
app:contentInsetEnd="0dp"
app:contentInsetLeft="0dp"
app:contentInsetRight="0dp"
app:contentInsetStart="0dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:id="@+id/imgbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:background="@android:color/transparent"
android:src="@mipmap/ic_launcher" />
<TextView
android:id="@+id/txt_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_toEndOf="@+id/btn_back"
android:layout_toRightOf="@+id/btn_back"
android:text="Weather"
android:textColor="@android:color/white"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
在主布局文件,使用下面行添加上述布局:
<include
android:id="@+id/toolbar"
layout="@layout/toolbar_actionbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"></include>
在你的风格,下面写在你的父主题线路:
<item name="android:windowActionBar">false</item>
<item name="windowNoTitle">true</item>
并添加以下行到你的活动:
Toolbar toolbar=(Toolbar)findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ImageButton imgbtn=(ImageButton)toolbar.findViewById(R.id.imgBtn);
相关问题
- 1. 在Android手机应用程序图标中显示徽章
- 2. 如何在Android的listview中显示应用程序图标?
- 3. 应用程序图标不显示在Android操作栏中
- 4. FontAwesome图标未显示在Android应用程序中[已修正]
- 5. 在Android中显示应用程序图标的徽章数
- 6. fontawesome图标不显示在Android应用程序中
- 7. 应用程序图标不显示在运行的应用程序,但它显示在启动器在android
- 8. 无法显示在Android应用程序菜单图标
- 9. 显示的是Android应用程序图标在浏览器
- 10. 图标不显示在Android应用程序
- 11. 在android应用程序中显示pdf
- 12. 显示图像的Android应用程序
- 13. 应用程序图标放大显示
- 14. 应用程序图标不显示
- 15. iPhone应用程序图标不显示
- 16. 应用程序图标显示
- 17. Android:facebook未显示应用程序图标
- 18. Phonegap android应用程序不显示我的应用程序图标:(
- 19. Android应用程序未在“所有应用程序”中显示
- 20. 应用程序compat actionbar v21应用程序图标未显示
- 21. 在Android应用程序中显示图表(不是图表)
- 22. 强制应用程序在OnCreate过程中显示TaskBar图标
- 23. 在android应用程序中使用grideview显示图像
- 24. 使用HTML5在Android应用程序中显示地图
- 25. Android - 如何在行动栏中显示应用程序徽标
- 26. Android应用程序的图标没有显示
- 27. 应用程序图标不显示(Android Studio)
- 28. PhoneGap android应用程序图标不显示
- 29. 显示默认图标启动器的Android应用程序
- 30. Android基于GPS的应用程序卫星图标不显示
尝试与其他新图标和 –
您需要使用自定义布局为你的动作条或工具栏重建项目。 – Drv
http://stackoverflow.com/questions/5350624/set-icon-for-android-application/5350771#5350771 –