【发布时间】:2018-12-24 18:33:13
【问题描述】:
我想创建顶部对齐的标签。我想知道是否可以使用app:menu/top_home_menu 添加menu.xml 内的项目中列出的图标。如果没有,还有比TabLayout.getTabAt(index).setIcon(directory)更简单的方法吗?
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentTop = "true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TabLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tabs"
android:background="@drawable/white_grey_boarder_top"
app:menu="@menu/top_home_menu">
</android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
</RelativeLayout>
</merge>
我觉得就像bottomnavigationbar如何通过制作单独的菜单来添加图标
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:background="@color/colorPrimary">
<android.support.design.widget.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/bottomNavViewBar"
android:background="@drawable/white_grey_boarder_top"
app:menu="@menu/bottom_navigation_menu">
</android.support.design.widget.BottomNavigationView>
</RelativeLayout>
</merge>
【问题讨论】:
标签: android icons android-tablayout