1

本文介绍了一个具体的Android应用程序UI布局案例,包含使用ConstraintLayout进行主界面布局及LinearLayout内多个UI组件如ImageView、TextView的配置方法。此外,还展示了RecyclerView的集成方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<?xml version="1.0" encoding="UTF-8"?>

-<android.support.constraint.ConstraintLayout tools:context="com.example.asus.my.MainActivity" android:layout_height="match_parent" android:layout_width="match_parent" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android">

<android.support.v7.widget.RecyclerView android:layout_height="match_parent" android:layout_width="match_parent" android:id="@+id/recycler_view"> </android.support.v7.widget.RecyclerView>

</android.support.constraint.ConstraintLayout>


<?xml version="1.0" encoding="UTF-8"?>

-<LinearLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:gravity="center_horizontal" android:orientation="vertical" android:layout_margin="20dp" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android">

<ImageView android:layout_height="200dp" android:layout_width="200dp" app:srcCompat="@mipmap/ic_launcher" android:scaleType="fitXY" android:id="@+id/imageView"/>

<TextView android:layout_height="wrap_content" android:layout_width="match_parent" android:gravity="center" android:id="@+id/textView" android:textSize="20dp" android:textColor="#000000" android:textStyle="bold" android:text="TextView" android:layout_marginTop="20dp"/>

<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:gravity="center" android:id="@+id/textView2" android:textColor="@color/colorAccent" android:text="TextView" android:layout_marginTop="14dp" android:layout_marginBottom="20dp"/>

<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:gravity="center" android:id="@+id/textView3" android:textColor="@color/colorWhite" android:text="查看商品 >" android:background="@color/colorAccent" android:padding="10dp"/>

</LinearLayout>

<?xml version="1.0" encoding="UTF-8"?>

-<LinearLayout android:layout_height="match_parent" android:layout_width="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android">

<ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" app:srcCompat="@mipmap/ic_launcher" android:layout_weight="1" android:id="@+id/imageView2"/>

</LinearLayout>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值