为什么图像在 TabLayout 的中心?
Why are images in the centre on TabLayout?
我针对不同的屏幕进行了不同的设计 sizes.Normal 屏幕尺寸图像看起来像我 want.I 遇到了这个错误并且找不到解决方案。
更改 Tablayout 的大小无效。enter image description here
enter image description here
我在两个设计中使用相同的代码
<androidx.coordinatorlayout.widget.CoordinatorLayout 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="match_parent"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:theme="@style/AppBarOverlay">
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@drawable/banner"
app:layout_anchor="@+id/appBarLayout"
app:layout_anchorGravity="center"
app:tabIndicatorColor="#00b7fa">
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@drawable/buyutec50" />
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@drawable/plus50" />
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@drawable/table50" />
</com.google.android.material.tabs.TabLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
将 app:tabMaxWidth="0dp" 添加到您的所有选项卡项目。
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:tabMaxWidth="0dp"
android:icon="@drawable/buyutec50" />
我针对不同的屏幕进行了不同的设计 sizes.Normal 屏幕尺寸图像看起来像我 want.I 遇到了这个错误并且找不到解决方案。 更改 Tablayout 的大小无效。enter image description here
enter image description here
我在两个设计中使用相同的代码
<androidx.coordinatorlayout.widget.CoordinatorLayout 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="match_parent"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:theme="@style/AppBarOverlay">
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@drawable/banner"
app:layout_anchor="@+id/appBarLayout"
app:layout_anchorGravity="center"
app:tabIndicatorColor="#00b7fa">
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@drawable/buyutec50" />
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@drawable/plus50" />
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@drawable/table50" />
</com.google.android.material.tabs.TabLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
将 app:tabMaxWidth="0dp" 添加到您的所有选项卡项目。
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:tabMaxWidth="0dp"
android:icon="@drawable/buyutec50" />