我正在构建一个简单的应用程序,我想在两个文本视图中提供一个“框架”,如下所示:

我试过了(但不是很成功!)使用RelativeLayout、TableLayout等。
什么是最简单的方式,请和一个简单的例子将是绝对辉煌的,如果可能的?非常感谢。
发布于 2021-02-10 19:31:47
您可以使用具有垂直方向的LinearLayout来实现这种layout以及形状drawable作为background,如下所示
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="120dp"
android:layout_height="60dp"
android:orientation="vertical"
android:gravity="center"
android:background="@drawable/frame_border"
tools:src="@drawable/default_avatar">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000"
android:text="TextView 1" />
<TextView
android:layout_width="wrap_content"
android:textAllCaps="true"
android:textColor="#000"
android:layout_marginTop="4dp"
android:layout_height="wrap_content"
android:text="30 cm" />
</LinearLayout>对于background,请在frame_border.xml下面使用
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:color="#000" android:width="4dp"/>
<corners android:radius="30dp"/>
</shape>https://stackoverflow.com/questions/66143637
复制相似问题