Android 布局帮助 - 具有静态高度和覆盖背景图像的行

Android Layout Help - rows with static height and covered background image

我是 Android 开发的新手。我已经搜索并尝试了几乎所有我发现的东西,但我无法创建下面的布局。基本上它将是背景图像和文本中间左对齐的行。我希望所有行都是静态高度和背景图像被覆盖(像这样:css)。

不是很清楚,但你可以试试LinearLayout(垂直)里面 RelativeLayout 每个项目的高度固定。在RelativeLayoutaa ImageView 带有 match_parent 的项目背景,比例类型为 centerTextView 用于带有填充的文本:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="100dp">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/btn_alert_1"
            android:scaleType="center"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="blabla"
            android:textColor="@android:color/holo_green_dark"
            android:paddingLeft="50dp"
            android:paddingTop="40dp"/>
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="100dp">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/btn_alert_2"
            android:scaleType="center"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="blabla"
            android:textColor="@android:color/holo_green_dark"
            android:paddingLeft="50dp"
            android:paddingTop="40dp"/>
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="100dp">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/btn_alert_1"
            android:scaleType="center"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="blabla"
            android:textColor="@android:color/holo_green_dark"
            android:paddingLeft="50dp"
            android:paddingTop="40dp"/>
    </RelativeLayout>
</LinearLayout>

关于 Android 比例类型的文档:https://developer.android.com/reference/android/widget/ImageView.ScaleType.html