CardView (LinearLayout) 中有两个 MaterialButton。单击按钮时,不会选择将鼠标悬停在按钮上时设计器中显示的整个区域(该区域在图片中用红色矩形标记)。如何使当您单击按钮时,按钮上的整个区域被选中。只是当你点击按钮时,它们之间形成了某种形象,这是不应该的。
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorBackgroundSetting"
tools:context=".Settings">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardPreventCornerOverlap="false"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.google.android.material.button.MaterialButton
style="@style/SettingButtons"
android:text="@string/change_email">
</com.google.android.material.button.MaterialButton>
<View
android:id="@+id/view1"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:background="@android:color/darker_gray"/>
<com.google.android.material.button.MaterialButton
style="@style/SettingButtons"
android:text="@string/change_password">
</com.google.android.material.button.MaterialButton>
</LinearLayout>
</androidx.cardview.widget.CardView>
<style name="SettingButtons" parent="Widget.MaterialComponents.Button.TextButton">
<item name="android:gravity">fill_vertical</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">match_parent</item>
<item name="android:textColor">@color/colorTextSetting</item>
<item name="android:textSize">@dimen/text_size</item>
<item name="android:textAllCaps">false</item>
<item name="icon">@drawable/ic_chevron_right_black_24dp</item>
<item name="iconTint">@color/colorTextSetting</item>
<item name="iconGravity">end</item>
</style>
在样式中添加两行。这应该可以解决问题
试试这个标记: