android - 安卓用户界面元素
问题描述
我想创建一个 UI 类似这样的列表。
我无法使用两个 TextView 创建相同的 UI。请帮我弄清楚如何仅使用两个 TextView 来创建此 UI。
名称的第一个 TextView (James)
消息的第二个 TextView (带我...)
提前致谢。
解决方案
您可以像这样使用约束布局
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/textTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:constraintStart_toEndOf="@id/image"
app:constraintEnd_toEndOf="parent" />
<TextView
android:id="@+id/textMessage"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:constraintTop_topBottomOf="@id/textTitle"
app:constraintStart_toEndOf="@id/image"
app:constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
推荐阅读
- reactjs - Typescript - 在 Redux 中定义初始状态时设置 null 属性的类型
- xamarin.android - 如何使所有活动(MainActivity 除外)同时具有带有标题和后退按钮的 ActionBar/Toolbar?(Xamarin.Android)
- python - 将随机数据字符串插入新的数据框列
- python - Networkx 忽略最短路径中具有特定属性值的节点
- node.js - node js 版本中实体太大(express": "^4.17.1",)
- angular - 构建角度通用应用程序时出错
- c# - c# 在母版页中设置覆盖用户
- python - 如何在 Python 中迭代“groupBy”返回的对象?
- vb.net - 如果我的电视显示器未在 VB.NET 中连接到我的计算机,如何禁止屏幕分割
- javascript - 将 Stripe JS 集成到 Laravel 6.0:[Vue 警告]:编译模板时出错: