material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

Last TabItem rendering error

Open kuyu132 opened this issue 1 year ago • 0 comments
trafficstars

Description:

As shown in the figure, several TabLayouts were created in the demo, and the backgrounds of rounded rectangles were set for TabLayout and TabItem, but the last TabItem displayed abnormally and the rounded rectangle on the right was cut.

Expected behavior:

rendering normal

Source code:

layout xml file

 <com.google.android.material.tabs.TabLayout
        android:id="@+id/tlIcon1"
        android:layout_width="wrap_content"
        android:layout_height="38dp"
        android:layout_marginTop="@dimen/dp_10"
        android:background="@drawable/shape_bg_ffffff_15_corner_18"
        android:orientation="horizontal"
        android:paddingHorizontal="2dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/tlIcon"
        app:tabBackground="@color/transparent"
        app:tabIndicator="@drawable/shape_full_tab_indicator"
        app:tabIndicatorColor="#FF39393D"
        app:tabIndicatorGravity="center"
        app:tabIndicatorHeight="34dp"
        app:tabMode="fixed"
        app:tabRippleColor="@color/transparent"
        app:tabTextAppearance="@style/TabLayoutTextStyle">

        <com.google.android.material.tabs.TabItem
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:icon="@drawable/ic_result_success_80" />

        <com.google.android.material.tabs.TabItem
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:icon="@drawable/ic_result_fail_80" />
    </com.google.android.material.tabs.TabLayout>

shape_bg_ffffff_15_corner_18.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:shape="rectangle"
    tools:ignore="ResourceName">

    <solid android:color="#FF1C1C1E" />

    <corners android:radius="8dp" />

</shape>

shape_full_tab_indicator.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android"
    tools:ignore="ResourceName">
    <item>
        <shape>
            <corners android:radius="6dp" />
            <solid android:color="#FF39393D" />
        </shape>
    </item>
</layer-list>

Android API version:33

Material Library version:1.11.0

Device:Pixel 7pro

image

kuyu132 avatar Jan 24 '24 03:01 kuyu132