Android AppCompatButton 在屏幕下方看起来确实很奇怪

Android AppCompatButton does look crazy in lower part of the screen

有人解释一下 viepager2 中的以下行为,以及为什么按下的按钮的角度会这样变化?

在第一张图片中,按下了第一个按钮。 第二个是第 6 个按钮(看起来很疯狂)。

在代码中您可以看到我的布局和按钮样式下方。 我确实将按钮更改为 material 按钮,但这并没有解决问题。

不知道view/angle这个点的变化是从哪里来的

<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="17">

    <com.google.android.material.textview.MaterialTextView
        android:gravity="center"
        android:layout_gravity="center"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:text="@string/app_name"
        android:layout_weight="1" />

    <androidx.appcompat.widget.AppCompatTextView
        style="@style/rv_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:textAlignment="center"
        android:gravity="center" />

    <androidx.appcompat.widget.LinearLayoutCompat
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="7"
        android:orientation="vertical"
        android:layout_marginHorizontal="8dp">


        <androidx.appcompat.widget.AppCompatButton
            style="@style/style" />

        <androidx.appcompat.widget.AppCompatButton
            style="@style/style" />

        <androidx.appcompat.widget.AppCompatButton
            style="@style/style" />

    </androidx.appcompat.widget.LinearLayoutCompat>


    <androidx.appcompat.widget.AppCompatTextView
        style="@style/rv_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:textAlignment="center"
        android:gravity="center" />

    <androidx.appcompat.widget.LinearLayoutCompat
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="7"
        android:orientation="vertical"
        android:layout_marginHorizontal="8dp">

        <androidx.appcompat.widget.AppCompatButton
            android:id="@+id/isearch_button0"
            style="@style/style" />

        <androidx.appcompat.widget.AppCompatButton
            android:id="@+id/isearch_button1"
            style="@style/style" />

        <androidx.appcompat.widget.AppCompatButton
            style="@style/style" />

        <androidx.appcompat.widget.AppCompatButton
            style="@style/style" />


    </androidx.appcompat.widget.LinearLayoutCompat>

</androidx.appcompat.widget.LinearLayoutCompat>

<style name="style">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:textColor">@android:color/black</item>
    <item name="android:text">@string/templateTypeAnswer_male</item>
    <item name="android:backgroundTint">@android:color/transparent</item>
</style>

在您的 style 中,您已将 backgroundTint 设置为透明,默认情况下每个 AppCompatButton 添加的阴影不支持,因此您可以看到一些故障。如果你需要真正透明的 Button 然后使用 background 属性,但是你会失去阴影(因为在“material”世界中透明对象下没有阴影)。如果你需要灰色模糊背景(又名“只有阴影”),那么为此目的使用一些自定义 drawable ,也设置为 background 属性。然后您还可以将 StateListAnimator 设置为 null - 此属性是“添加”阴影(不是 backgroundbackgroundTint)以及具有 elevation 变化的动画按下时。 null 将删除此功能(放在下面 style

<item name="android:stateListAnimator">@null</item>