如何为 "BottomNavigationView" 的菜单图标设置图像,因为它只显示图像的设计,即结构....?
How to set an image for menu icon for "BottomNavigationView", as it's displaying only image's design i.e. structure....?
我想为我的 BottomNavigationView 的 菜单项 设置特定图像,因为当我使用 drawable 设置图像时,其不能正常工作。
你能指导我如何为 activity...显示后退按钮吗?
这是我的代码。
selectedActivity.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".selectedJokesActivity">
<FrameLayout
android:id="@+id/frame"
android:layout_width="match_parent"
android:layout_height="454dp">
</FrameLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/navigation" />
</android.support.constraint.ConstraintLayout>
selectedActivity.xml
我的截图 activity:-
Real device: Android Oreo
menu/navigation.xml :-
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/navigation_home"
android:icon="@drawable/digital"
android:title="@string/title_home" />
<item
android:id="@+id/navigation_dashboard"
android:icon="@drawable/ic_dashboard_black_24dp"
android:title="@string/title_dashboard" />
<item
android:id="@+id/navigation_notifications"
android:icon="@drawable/ic_notifications_black_24dp"
android:title="@string/title_notifications" />
</menu>
请帮忙....
How to set back button only at the action bar...?
只需在 onCreate()
中添加以下行
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
试试这个希望它会工作...!
Menu BVMenu = bottomNavigationView.getMenu();
BVMenu.setItemIconTintList(null);
BVMenu.findItem(R.id.Your_action_Name).setIcon(Drawable_Name);
要获得图标图像的实际颜色或结构,请使用:
bottomNavigationView.setItemIconTintList(null);
我想为我的 BottomNavigationView 的 菜单项 设置特定图像,因为当我使用 drawable 设置图像时,其不能正常工作。
你能指导我如何为 activity...显示后退按钮吗?
这是我的代码。
selectedActivity.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".selectedJokesActivity">
<FrameLayout
android:id="@+id/frame"
android:layout_width="match_parent"
android:layout_height="454dp">
</FrameLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/navigation" />
</android.support.constraint.ConstraintLayout>
selectedActivity.xml
我的截图 activity:-
Real device: Android Oreo
menu/navigation.xml :-
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/navigation_home"
android:icon="@drawable/digital"
android:title="@string/title_home" />
<item
android:id="@+id/navigation_dashboard"
android:icon="@drawable/ic_dashboard_black_24dp"
android:title="@string/title_dashboard" />
<item
android:id="@+id/navigation_notifications"
android:icon="@drawable/ic_notifications_black_24dp"
android:title="@string/title_notifications" />
</menu>
请帮忙....
How to set back button only at the action bar...?
只需在 onCreate()
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
试试这个希望它会工作...!
Menu BVMenu = bottomNavigationView.getMenu();
BVMenu.setItemIconTintList(null);
BVMenu.findItem(R.id.Your_action_Name).setIcon(Drawable_Name);
要获得图标图像的实际颜色或结构,请使用:
bottomNavigationView.setItemIconTintList(null);