android 左侧为布局图像,右侧为两个文本块

android layout image at left and two text block at right

我想要这样的布局 Layout where an image at the bottom and two text block at right

这是一个非常简单的布局,左边是一张图片,右边是两个文本块。我知道如何在 html 和 CSS 中执行此操作,但不知道如何在 XML 中执行此操作。使元素向左或向右浮动的属性是什么?现在,如果我添加一个图像和两个文本块,则不会显示第二个文本块。

您可以为此使用相对布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_height="wrap_content"
            android:layout_width="match_parent">
    <ImageView android:id="@+id/img" 
           android:layout_height="wrap_content"
           android:layout_width="wrap_content" 
           android:src="@drawable/ic_clear"/>
    <TextView android:id="@+id/text1"
          android:layout_height="wrap_content"
          android:layout_toEndOf="@+id/img"
          android:layout_toRightOf="@+id/img"
          android:layout_width="match_parent"
          android:text="text 1"/>
    <TextView android:layout_below="@+id/text1"
          android:layout_height="wrap_content"
          android:layout_toEndOf="@+id/img"
          android:layout_toRightOf="@+id/img"
          android:layout_width="match_parent"
          android:text="text 2"/>
</RelativeLayout>

试试这段代码,我已经测试过了:

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

<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:layout_gravity="center"
    android:layout_weight="1"/>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:layout_weight="1"
        android:gravity="center"/>

</LinearLayout>

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

<LinearLayout
   android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:orientation="vertical">

<TextView
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"/>

<TextView
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"/>

</LinearLayout>

    <ImageView
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="match_parent" />
</LinearLayout>

自行编辑:)