要在除了' +' 按钮的每个 Button 上显示三个信息,可以使用一个自定义的布局来替代原来的 Button,并在该布局中添加三个 TextView 来显示任务名、任务时间和任务描述。请将以下代码替换你的布局文件中的每个 Button:

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

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/Radio_button"
        android:background="@drawable/yangpi"
        android:textAllCaps="false"
        android:visibility="gone"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:background="@drawable/yangpi"
        android:padding="10dp">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="任务名"
            android:textSize="16sp"
            android:textColor="#000000"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="任务时间"
            android:textSize="14sp"
            android:textColor="#808080"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="任务描述"
            android:textSize="14sp"
            android:textColor="#808080"/>

    </LinearLayout>

</LinearLayout>

在这个布局中,我们使用了一个 LinearLayout 作为 Button 的容器,并设置了背景和内边距。在 LinearLayout 中,我们添加了三个 TextView 来显示任务名、任务时间和任务描述。你可以根据需要修改 TextView 的样式和属性。

请注意,我们将原来的 Button 的可见性设置为了'gone',这样它将不会显示在界面上,只有' +' 按钮会显示。

你需要将这个布局代码替换每个 Button 的代码,但保留 Button 的 id 和其他属性不变。这样,你就可以在每个 Button 上显示三个信息了。

Android 开发:自定义布局显示任务信息

原文地址: https://www.cveoy.top/t/topic/Saq 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录