【发布时间】:2021-09-28 23:32:09
【问题描述】:
真的很奇怪的行为。我有一个简单的布局,一列中有 4 个图像视图,与下一列的 4 个按钮相匹配。我使用了渐变(微妙)背景图像 - 从左到右从暗到亮。
图像视图背景图像可以正确显示,因为它位于背景图像的左侧,因此背景颜色较深。然而,按钮背景图像与渐变方向相反。
图像和按钮视图都使用相同的背景图像。我不明白为什么背景图像会在按钮上翻转。有什么想法吗?
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".IndexMenuActivity">
<LinearLayout
android:layout_width="75dp"
android:layout_height="match_parent"
android:layout_marginLeft="0sp"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.25"
android:background="@drawable/redbkg"
app:srcCompat="@drawable/i_ax" />
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.25"
android:background="@drawable/bluebkg"
app:srcCompat="@drawable/i_mx" />
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.25"
android:background="@drawable/greenbkg"
app:srcCompat="@drawable/i_ref" />
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.25"
android:background="@drawable/yellowbkg"
app:srcCompat="@drawable/i_cal" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="75dp"
android:orientation="vertical">
<Button
android:id="@+id/imageButton1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.25"
android:background="@drawable/redbkg"
android:onClick="subjectListMx"
android:text="ASSESSMENT"
android:textAppearance="@style/TextAppearance.AppCompat.Title"
android:textColor="#FFFFFF"
android:textSize="34sp" />
<Button
android:id="@+id/imageButton2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.25"
android:background="@drawable/bluebkg"
android:onClick="subjectListMx"
android:text="MANAGEMENT"
android:textColor="#FFFFFF"
android:textSize="34sp" />
<Button
android:id="@+id/imageButton3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.25"
android:background="@drawable/greenbkg"
android:onClick="subjectListRef"
android:text="REFERENCE"
android:textColor="#FFFFFF"
android:textSize="34sp"/>
<Button
android:id="@+id/imageButton4"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.25"
android:background="@drawable/yellowbkg"
android:onClick="subjectListCal"
android:text="CALCULATOR"
android:textColor="#FFFFFF"
android:textSize="34sp"/>
</LinearLayout></androidx.constraintlayout.widget.ConstraintLayout>
【问题讨论】: