Android 如何在图片上创建用户界面
我正在开发新闻android应用程序,如何创建如下图所示的ui 下面是我的xml文件,但它不是我想要的输出Android 如何在图片上创建用户界面,android,textview,imageview,cardview,Android,Textview,Imageview,Cardview,我正在开发新闻android应用程序,如何创建如下图所示的ui 下面是我的xml文件,但它不是我想要的输出 <?xml version="1.0" encoding="utf-8"?> <androidx.cardview.widget.CardView android:layout_width="wrap_content" android:layout_height="wrap_content" xmlns:card_view="http://schemas.
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView 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="25dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:layout_width="60dp"
android:contentDescription="@string/bbc_sport"
android:layout_height="60dp"/>
<TextView
android:id="@+id/articleTitle"
android:layout_width="match_parent"
android:layout_height="30dp"
android:paddingStart="60dp"
android:paddingLeft="100dp" />
<TextView
android:id="@+id/articleTitle"
android:layout_width="match_parent"
android:layout_height="30dp"
android:paddingStart="60dp"
android:paddingLeft="100dp" />
</androidx.cardview.widget.CardView>
在您的代码中尝试这一点
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
card_view:cardPreventCornerOverlap="false"
card_view:cardCornerRadius="25dp">
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"/>
</android.support.v7.widget.CardView>
如果您指的是项目行,也许您可以这样做
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp">
<ImageView
android:id="@+id/imageView"
android:layout_width="100dp"
android:layout_height="85dp"
android:layout_marginStart="16dp"
android:contentDescription="bbc"
tools:background="@color/colorPrimary" />
<TextView
android:id="@+id/articleTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_toEndOf="@id/imageView"
android:ellipsize="end"
android:lines="3"
android:maxLines="3"
android:text="1\n2\n3\n" />
<ImageView
android:id="@+id/imageCategory"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_below="@id/articleTitle"
android:layout_marginStart="16dp"
android:layout_toEndOf="@id/imageView"
tools:background="@color/colorPrimary" />
<TextView
android:id="@+id/articleCategory"
android:layout_width="wrap_content"
android:layout_height="32dp"
android:layout_below="@id/articleTitle"
android:layout_marginStart="16dp"
android:layout_toEndOf="@id/imageCategory"
android:gravity="center|start"
android:text="Onefootbal" />
<TextView
android:id="@+id/articleTime"
android:layout_width="wrap_content"
android:layout_height="32dp"
android:layout_below="@id/articleTitle"
android:layout_alignParentEnd="true"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_toEndOf="@id/articleCategory"
android:gravity="center|start"
android:text="- 1h"
android:textColor="@android:color/darker_gray" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
为图像添加边框。那么...怎么样here@EdgarShvedskiyStackOverflow不是一个免费为您编写代码的服务。现在你没有显示任何尝试,你希望人们为你写完整的布局。。。我不认为这是正确的Pashol nahuy Jalab为什么你要使用卡片视图:cardCornerRadius=“25dp”
和android:layout\u width=“wrap\u content”
和android:layout\u height=“wrap\u content”