Distorted toggle button image

248 Views Asked by At

I have found several duplicate questions. I'm having exactly the same problem:

However, their problems haven't been solved yet so I just want to ask a new question again. So the third one on the left is what the second is supposed to be. The second button is a custom toggle button, the idea of which comes from here: Android: Create a toggle button with image and no text And I place these buttons in a horizontal LinearLayout.

enter image description here

This is the xml of that part:

<LinearLayout
        android:id="@+id/post_button_layout"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:orientation="horizontal"
        android:padding="16dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="@+id/post_content"
        app:layout_constraintHorizontal_bias="0.807"
        app:layout_constraintStart_toStartOf="@+id/post_content"
        app:layout_constraintTop_toBottomOf="@+id/post_divider2">

        <ImageButton
            android:id="@+id/post_comment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@android:drawable/screen_background_light_transparent"
            app:srcCompat="@drawable/ic_comment"
            tools:layout_editor_absoluteX="37dp"
            tools:layout_editor_absoluteY="500dp" />

        <ToggleButton
            android:id="@+id/toggleButton"
            style="@style/CollectToggle"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/ic_collect_toggle_bg"/>

        <ImageButton
            android:id="@+id/post_collect"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@android:drawable/screen_background_light_transparent"
            app:srcCompat="@drawable/ic_collection"
            tools:layout_editor_absoluteX="288dp"
            tools:layout_editor_absoluteY="508dp" />

        <ImageButton
            android:id="@+id/post_share"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@android:drawable/screen_background_light_transparent"
            app:srcCompat="@drawable/ic_share"
            tools:layout_editor_absoluteX="104dp"
            tools:layout_editor_absoluteY="508dp" />

</LinearLayout>
0

There are 0 best solutions below