【发布时间】:2021-03-04 09:06:41
【问题描述】:
我正在使用material library,并使用TabLayout 和三个TabItem。在这个TabItem 中,我使用了图标,我想让它变大,但我不知道是否可以更改图标大小。
这是我现在的 XML:
<com.google.android.material.tabs.TabLayout
android:id="@+id/tablayout"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline6"
app:tabBackground="@drawable/tab_background_color_selector"
app:tabIconTint="@color/white"
app:tabIndicator="@null">
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@drawable/icon_one"/>
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@drawable/icon_two"/>
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@drawable/icon_three"/>
</com.google.android.material.tabs.TabLayout>
【问题讨论】:
-
可以为您的 TabItems 提供完全自定义的视图(在代码中,而不是在 xml 中)。例如,请参阅this question。所以你基本上可以增加它们的大小,如果你愿意,可以做更多的事情。
-
stackoverflow.com/a/35372182/5684956 您可以使用自定义布局来灵活调整标签项的大小
标签: android android-layout material-design