Android仿淘宝页面布局

说明

该项目就是简单地仿造淘宝的一些页面,没有功能!!
icon是在网上找的尽量一样的,颜色是自己用PS吸出来的,尺寸是用PS量出来的。

运行环境

小米6 (分辨率1920*1080,尺寸5.15)

开发环境

AndroidStudio4.0

效果图

我的淘宝

在这里插入图片描述

消息 在这里插入图片描述
首页

在这里插入图片描述

百度网盘
提取码:2t9d

以下是Android仿淘宝商品详情页的实现方法: 1.首先,我们需要在布局文件中使用LinearLayout来实现整个页面的布局,具体代码如下: ```xml <LinearLayout android:id="@+id/ll_root" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <!-- 商品图片 --> <ImageView android:id="@+id/iv_product" android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@drawable/product_image"/> <!-- 商品标题 --> <TextView android:id="@+id/tv_title" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="这里是商品标题" android:textSize="18sp" android:textColor="#000000" android:padding="10dp"/> <!-- 商品价格 --> <TextView android:id="@+id/tv_price" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="¥ 100.00" android:textSize="16sp" android:textColor="#ff0000" android:padding="10dp"/> <!-- 商品描述 --> <TextView android:id="@+id/tv_description" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="这里是商品描述" android:textSize="14sp" android:textColor="#666666" android:padding="10dp"/> <!-- 商品详情 --> <TextView android:id="@+id/tv_detail" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="这里是商品详情" android:textSize="14sp" android:textColor="#666666" android:padding="10dp"/> <!-- 购买按钮 --> <Button android:id="@+id/btn_buy" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="立即购买" android:textSize="16sp" android:textColor="#ffffff" android:background="#ff0000" android:padding="10dp"/> </LinearLayout> ``` 2.在Java代码中,我们需要使用Activity或Fragment来管理整个页面,并使用ListView来展示商品的评论信息,具体代码如下: ```java public class ProductDetailActivity extends AppCompatActivity { private ImageView ivProduct; private TextView tvTitle; private TextView tvPrice; private TextView tvDescription; private TextView tvDetail; private Button btnBuy; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_product_detail); // 初始化视图组件 ivProduct = findViewById(R.id.iv_product); tvTitle = findViewById(R.id.tv_title); tvPrice = findViewById(R.id.tv_price); tvDescription = findViewById(R.id.tv_description); tvDetail = findViewById(R.id.tv_detail); btnBuy = findViewById(R.id.btn_buy); // 设置商品信息 ivProduct.setImageResource(R.drawable.product_image); tvTitle.setText("这里是商品标题"); tvPrice.setText("¥ 100.00"); tvDescription.setText("这里是商品描述"); tvDetail.setText("这里是商品详情"); // 设置购买按钮的点击事件 btnBuy.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO: 处理购买事件 } }); } } ```
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值