【发布时间】:2020-02-03 17:39:42
【问题描述】:
我正在开发 android 应用程序,如何创建如下图所示的用户界面
在我的 xml 下面我玩过但它没有给出预期的输出任何建议将不胜感激并欢迎提示我不知道我到底在哪里犯了错误
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
card_view:cardPreventCornerOverlap="false"
card_view:cardCornerRadius="50dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/articleTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/articleSource"
android:paddingBottom="45dp"
android:text="22222222"
tools:layout_editor_absoluteX="25dp"
tools:layout_editor_absoluteY="16dp" />
<ImageView
android:layout_width="60dp"
android:contentDescription="@string/bbc_sport"
android:layout_height="60dp"/>
<TextView
android:id="@+id/articleSource"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="90dp"
android:text="News blalalalal"/>
<TextView
android:id="@+id/articleTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="90dp"
android:text="News blalalalal"/>
</androidx.constraintlayout.widget.ConstraintLayout
>
</androidx.cardview.widget.CardView>
【问题讨论】:
-
您好,您想知道如何在列表中构建行项布局还是整个布局?
-
您在该约束布局中没有正确使用任何东西。当您彻底浏览这些链接并应用它们时,它将正常工作。检查这些官方文档链接:developer.android.com/training/constraint-layoutcodelabs.developers.google.com/codelabs/constraint-layout/…