安卓仿购物车的Demo
2017-09-08 本文已影响0人
心中有梦丶身边有你
效果图:
N6QRQHNWFH1{MA0PM4)KB_T.png
activity的xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/shopping_title"
layout="@layout/layout_title" />
<TextView
android:id="@+id/tv_edit"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_gravity="right"
android:layout_margin="10dp"
android:text="编辑"
android:textSize="18dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@id/tv_edit"
android:background="@color/gray3" />
<ListView
android:id="@+id/list_shopping_cart"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="@id/tv_edit"
android:layout_weight="1"
android:scrollbars="none" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/gray3" />
<RelativeLayout
android:id="@+id/rl_bottom"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:background="@color/white">
<CheckBox
android:id="@+id/ck_all"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:button="@drawable/check_box_style"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:gravity="center"
android:paddingLeft="10dp"
android:scaleX="0.6"
android:scaleY="0.6"
android:text="全选"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/desccolor" />
<TextView
android:id="@+id/tv_settlement"
android:layout_width="80dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:background="@color/desccolor"
android:gravity="center"
android:text="结算(0)"
android:textColor="@color/white" />
<TextView
android:id="@+id/tv_show_price"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toLeftOf="@id/tv_settlement"
android:gravity="center"
android:padding="5dp"
android:text="合计:0.00"
android:textColor="@color/desccolor" />
</RelativeLayout>
</LinearLayout>
activity
package com.example.shoppingcart.shopp;
import android.util.SparseArray;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ListView;
import android.widget.TextView;
import com.example.shoppingcart.BaseActivity;
import com.example.shoppingcart.R;
import com.example.shoppingcart.ShoppingCartBean;
import java.util.ArrayList;
import java.util.List;
/**
* Created by AYD on 2016/11/21.
* 购物车页面
*/
public class ShoppingCartActivity extends BaseActivity implements View.OnClickListener
, ShoppingCartAdapter.CheckInterface, ShoppingCartAdapter.ModifyCountInterface {
public TextView tv_title, tv_settlement, tv_show_price;
private TextView tv_all_check;
private CheckBox ck_all;
private ListView list_shopping_cart;
private ShoppingCartAdapter shoppingCartAdapter;
private TextView tv_edit;
private boolean flag = false;
private List<ShoppingCartBean> shoppingCartBeanList = new ArrayList<>();
private boolean mSelect;
private double totalPrice = 0.00;// 购买的商品总价
private int totalCount = 0;// 购买的商品总数量
/**
* 批量模式下,用来记录当前选中状态
*/
private SparseArray<Boolean> mSelectState = new SparseArray<Boolean>();
@Override
protected int getLayout() {
return R.layout.layout_shopping_cart_activity;
}
@Override
protected void initView() {
tv_title = bindView(R.id.tv_title);
tv_title.setText("购物车");
list_shopping_cart = bindView(R.id.list_shopping_cart);
// list_shopping_cart.setOnItemClickListener(this);
ck_all = bindView(R.id.ck_all);
ck_all.setOnClickListener(this);
// ck_all.setOnCheckedChangeListener(this);
tv_show_price = bindView(R.id.tv_show_price);
tv_settlement = bindView(R.id.tv_settlement);
tv_settlement.setOnClickListener(this);
tv_edit = bindView(R.id.tv_edit);
tv_edit.setOnClickListener(this);
shoppingCartAdapter = new ShoppingCartAdapter(this);
shoppingCartAdapter.setCheckInterface(this);
shoppingCartAdapter.setModifyCountInterface(this);
list_shopping_cart.setAdapter(shoppingCartAdapter);
shoppingCartAdapter.setShoppingCartBeanList(shoppingCartBeanList);
}
@Override
protected void initData() {
for (int i = 0; i < 6; i++) {
ShoppingCartBean shoppingCartBean = new ShoppingCartBean();
shoppingCartBean.setShoppingName("高端大气上档次的T桖");
shoppingCartBean.setFabric("纯棉");
shoppingCartBean.setDressSize(48);
shoppingCartBean.setPantsSize(65);
shoppingCartBean.setPrice(60);
shoppingCartBean.setCount(2);
shoppingCartBeanList.add(shoppingCartBean);
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
//全选按钮
case R.id.ck_all:
if (shoppingCartBeanList.size() != 0) {
if (ck_all.isChecked()) {
for (int i = 0; i < shoppingCartBeanList.size(); i++) {
shoppingCartBeanList.get(i).setChoosed(true);
}
shoppingCartAdapter.notifyDataSetChanged();
} else {
for (int i = 0; i < shoppingCartBeanList.size(); i++) {
shoppingCartBeanList.get(i).setChoosed(false);
}
shoppingCartAdapter.notifyDataSetChanged();
}
}
statistics();
break;
case R.id.tv_edit:
flag = !flag;
if (flag) {
tv_edit.setText("完成");
shoppingCartAdapter.isShow(false);
} else {
tv_edit.setText("编辑");
shoppingCartAdapter.isShow(true);
}
break;
}
}
// /**
// * 全选 反选
// *
// * @param buttonView
// * @param isChecked
// */
// @Override
// public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// if (shoppingCartBeanList.size() != 0) {
// if (isChecked) {
// for (int i = 0; i < shoppingCartBeanList.size(); i++) {
// shoppingCartBeanList.get(i).setChoosed(true);
// }
// shoppingCartAdapter.notifyDataSetChanged();
// } else {
// for (int i = 0; i < shoppingCartBeanList.size(); i++) {
// shoppingCartBeanList.get(i).setChoosed(false);
// }
// shoppingCartAdapter.notifyDataSetChanged();
// }
// }
// statistics();
// }
/**
* 单选
*
* @param position 组元素位置
* @param isChecked 组元素选中与否
*/
@Override
public void checkGroup(int position, boolean isChecked) {
shoppingCartBeanList.get(position).setChoosed(isChecked);
if (isAllCheck())
ck_all.setChecked(true);
else
ck_all.setChecked(false);
shoppingCartAdapter.notifyDataSetChanged();
statistics();
}
/**
* 遍历list集合
*
* @return
*/
private boolean isAllCheck() {
for (ShoppingCartBean group : shoppingCartBeanList) {
if (!group.isChoosed())
return false;
}
return true;
}
/**
* 统计操作
* 1.先清空全局计数器<br>
* 2.遍历所有子元素,只要是被选中状态的,就进行相关的计算操作
* 3.给底部的textView进行数据填充
*/
public void statistics() {
totalCount = 0;
totalPrice = 0.00;
for (int i = 0; i < shoppingCartBeanList.size(); i++) {
ShoppingCartBean shoppingCartBean = shoppingCartBeanList.get(i);
if (shoppingCartBean.isChoosed()) {
totalCount++;
totalPrice += shoppingCartBean.getPrice() * shoppingCartBean.getCount();
}
}
tv_show_price.setText("合计:" + totalPrice);
tv_settlement.setText("结算(" + totalCount + ")");
}
/**
* 增加
*
* @param position 组元素位置
* @param showCountView 用于展示变化后数量的View
* @param isChecked 子元素选中与否
*/
@Override
public void doIncrease(int position, View showCountView, boolean isChecked) {
ShoppingCartBean shoppingCartBean = shoppingCartBeanList.get(position);
int currentCount = shoppingCartBean.getCount();
currentCount++;
shoppingCartBean.setCount(currentCount);
((TextView) showCountView).setText(currentCount + "");
shoppingCartAdapter.notifyDataSetChanged();
statistics();
}
/**
* 删减
*
* @param position 组元素位置
* @param showCountView 用于展示变化后数量的View
* @param isChecked 子元素选中与否
*/
@Override
public void doDecrease(int position, View showCountView, boolean isChecked) {
ShoppingCartBean shoppingCartBean = shoppingCartBeanList.get(position);
int currentCount = shoppingCartBean.getCount();
if (currentCount == 1) {
return;
}
currentCount--;
shoppingCartBean.setCount(currentCount);
((TextView) showCountView).setText(currentCount + "");
shoppingCartAdapter.notifyDataSetChanged();
statistics();
}
/**
* 删除
* @param position
*/
@Override
public void childDelete(int position) {
shoppingCartBeanList.remove(position);
shoppingCartAdapter.notifyDataSetChanged();
statistics();
}
}
ShoppingCartAdapter
package com.example.shoppingcart.shopp;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.example.shoppingcart.R;
import com.example.shoppingcart.ShoppingCartBean;
import java.util.List;
/**
* Created by AYD on 2016/11/21.
* <p/>
* 购物车Adapter
*/
public class ShoppingCartAdapter extends BaseAdapter {
private boolean isShow = true;//是否显示编辑/完成
private List<ShoppingCartBean> shoppingCartBeanList;
private CheckInterface checkInterface;
private ModifyCountInterface modifyCountInterface;
private Context context;
public ShoppingCartAdapter(ShoppingCartActivity context) {
this.context = context;
}
public void setShoppingCartBeanList(List<ShoppingCartBean> shoppingCartBeanList) {
this.shoppingCartBeanList = shoppingCartBeanList;
notifyDataSetChanged();
}
/**
* 单选接口
*
* @param checkInterface
*/
public void setCheckInterface(CheckInterface checkInterface) {
this.checkInterface = checkInterface;
}
/**
* 改变商品数量接口
*
* @param modifyCountInterface
*/
public void setModifyCountInterface(ModifyCountInterface modifyCountInterface) {
this.modifyCountInterface = modifyCountInterface;
}
@Override
public int getCount() {
return shoppingCartBeanList == null ? 0 : shoppingCartBeanList.size();
}
@Override
public Object getItem(int position) {
return shoppingCartBeanList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
/**
* 是否显示可编辑
*
* @param flag
*/
public void isShow(boolean flag) {
isShow = flag;
notifyDataSetChanged();
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.item_shopping_cart_layout, parent, false);
holder = new ViewHolder(convertView);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
final ShoppingCartBean shoppingCartBean = shoppingCartBeanList.get(position);
holder.tv_commodity_name.setText(shoppingCartBean.getShoppingName());
holder.tv_fabric.setText("面料:" + shoppingCartBean.getFabric());
holder.tv_dress.setText("西服尺寸:" + shoppingCartBean.getDressSize());
holder.tv_pants.setText("西裤尺寸:" + shoppingCartBean.getPantsSize());
holder.tv_price.setText("¥:" + shoppingCartBean.getPrice());
holder.ck_chose.setChecked(shoppingCartBean.isChoosed());
holder.tv_show_num.setText(shoppingCartBean.getCount() + "");
holder.tv_num.setText("X" + shoppingCartBean.getCount());
//单选框按钮
holder.ck_chose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
shoppingCartBean.setChoosed(((CheckBox) v).isChecked());
checkInterface.checkGroup(position, ((CheckBox) v).isChecked());//向外暴露接口
}
}
);
//增加按钮
holder.iv_add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
modifyCountInterface.doIncrease(position, holder.tv_show_num, holder.ck_chose.isChecked());//暴露增加接口
}
});
//删减按钮
holder.iv_sub.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
modifyCountInterface.doDecrease(position, holder.tv_show_num, holder.ck_chose.isChecked());//暴露删减接口
}
});
//删除弹窗
holder.tv_delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog alert = new AlertDialog.Builder(context).create();
alert.setTitle("操作提示");
alert.setMessage("您确定要将这些商品从购物车中移除吗?");
alert.setButton(DialogInterface.BUTTON_NEGATIVE, "取消",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
return;
}
});
alert.setButton(DialogInterface.BUTTON_POSITIVE, "确定",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
modifyCountInterface.childDelete(position);//删除 目前只是从item中移除
}
});
alert.show();
}
});
//判断是否在编辑状态下
if (isShow) {
holder.tv_commodity_name.setVisibility(View.VISIBLE);
holder.tv_fabric.setVisibility(View.VISIBLE);
holder.rl_edit.setVisibility(View.GONE);
holder.tv_delete.setVisibility(View.GONE);
} else {
holder.tv_commodity_name.setVisibility(View.GONE);
holder.tv_fabric.setVisibility(View.GONE);
holder.rl_edit.setVisibility(View.VISIBLE);
holder.tv_delete.setVisibility(View.VISIBLE);
}
return convertView;
}
//初始化控件
class ViewHolder {
ImageView iv_chose;
ImageView iv_show_pic, iv_sub, iv_add;
TextView tv_commodity_name, tv_fabric, tv_dress, tv_pants, tv_price, tv_num, tv_delete, tv_show_num;
CheckBox ck_chose;
RelativeLayout rl_edit;
public ViewHolder(View itemView) {
ck_chose = (CheckBox) itemView.findViewById(R.id.ck_chose);
iv_show_pic = (ImageView) itemView.findViewById(R.id.iv_show_pic);
iv_sub = (ImageView) itemView.findViewById(R.id.iv_sub);
iv_add = (ImageView) itemView.findViewById(R.id.iv_add);
tv_commodity_name = (TextView) itemView.findViewById(R.id.tv_commodity_name);
tv_fabric = (TextView) itemView.findViewById(R.id.tv_fabric);
tv_dress = (TextView) itemView.findViewById(R.id.tv_dress);
tv_pants = (TextView) itemView.findViewById(R.id.tv_pants);
tv_price = (TextView) itemView.findViewById(R.id.tv_price);
tv_num = (TextView) itemView.findViewById(R.id.tv_num);
tv_delete = (TextView) itemView.findViewById(R.id.tv_delete);
tv_show_num = (TextView) itemView.findViewById(R.id.tv_show_num);
rl_edit = (RelativeLayout) itemView.findViewById(R.id.rl_edit);
}
}
/**
* 复选框接口
*/
public interface CheckInterface {
/**
* 组选框状态改变触发的事件
*
* @param position 元素位置
* @param isChecked 元素选中与否
*/
void checkGroup(int position, boolean isChecked);
}
/**
* 改变数量的接口
*/
public interface ModifyCountInterface {
/**
* 增加操作
*
* @param position 组元素位置
* @param showCountView 用于展示变化后数量的View
* @param isChecked 子元素选中与否
*/
void doIncrease(int position, View showCountView, boolean isChecked);
/**
* 删减操作
*
* @param position 组元素位置
* @param showCountView 用于展示变化后数量的View
* @param isChecked 子元素选中与否
*/
void doDecrease(int position, View showCountView, boolean isChecked);
/**
* 删除子item
*
* @param position
*/
void childDelete(int position);
}
}
BaseActivity:
package com.example.shoppingcart;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.TypedValue;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
/**
* Created by AYD on 2016/10/24.
* 基类 Activity
*/
public abstract class BaseActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// StatusBarCompat.compat(this, R.color.blue_news);
// initSystemBarTint();
setContentView(getLayout());
// ActivityControl.addAty(this);
initView();
initData();
}
protected abstract int getLayout();
protected abstract void initView();
protected abstract void initData();
protected <T extends View> T bindView(int id) {
return (T) findViewById(id);
}
@Override
protected void onDestroy() {
super.onDestroy();
}
/**
* 子类可以重写改变状态栏颜色
*/
protected int setStatusBarColor() {
return getColorPrimary();
}
/**
* 子类可以重写决定是否使用透明状态栏
*/
protected boolean translucentStatusBar() {
return false;
}
protected void initSystemBarTint() {
Window window = getWindow();
if (translucentStatusBar()) {
// 设置状态栏全透明
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.TRANSPARENT);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
return;
}
// 沉浸式状态栏
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//5.0以上使用原生方法
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(setStatusBarColor());
}
}
/**
* 获取主题色
*/
public int getColorPrimary() {
TypedValue typedValue = new TypedValue();
getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, true);
return typedValue.data;
}
}
封装的 ShoppingCartBean
package com.example.shoppingcart;
/**
* Created by AYD on 2016/11/22.
* <p>
* 购物车
*/
public class ShoppingCartBean {
private int id;
private String imageUrl;
private String shoppingName;
private String fabric;
private int dressSize;
private int pantsSize;
private double price;
private int num;
public boolean isChoosed;
public boolean isCheck = false;
private int count;
public ShoppingCartBean() {}
public ShoppingCartBean(int id, String shoppingName, String fabric, int dressSize,
int pantsSize, double price, int num, int count) {
this.id = id;
this.shoppingName = shoppingName;
this.fabric = fabric;
this.dressSize = dressSize;
this.pantsSize = pantsSize;
this.price = price;
this.num = num;
this.count = count;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public boolean isChoosed() {
return isChoosed;
}
public void setChoosed(boolean choosed) {
isChoosed = choosed;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public String getShoppingName() {
return shoppingName;
}
public void setShoppingName(String shoppingName) {
this.shoppingName = shoppingName;
}
public String getFabric() {
return fabric;
}
public void setFabric(String fabric) {
this.fabric = fabric;
}
public int getDressSize() {
return dressSize;
}
public void setDressSize(int dressSize) {
this.dressSize = dressSize;
}
public int getPantsSize() {
return pantsSize;
}
public void setPantsSize(int pantsSize) {
this.pantsSize = pantsSize;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
}
check_box_style:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<-ck_select和ck_normal是选中和未选中的两张图片->
<item android:drawable="@drawable/ck_select" android:state_checked="true"></item>
<item android:drawable="@drawable/ck_select" android:state_selected="true"></item>
<item android:drawable="@drawable/ck_select" android:state_pressed="true"></item>
<item android:drawable="@drawable/ck_normal"></item>
</selector>
item_shopping_cart_layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="190dp"
android:orientation="vertical">
<CheckBox
android:id="@+id/ck_chose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="8dp"
android:button="@drawable/check_box_style"
android:scaleX="0.6"
android:scaleY="0.6" />
<ImageView
android:id="@+id/iv_show_pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/ck_chose"
android:background="@mipmap/demo" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="30dp"
android:layout_toRightOf="@id/iv_show_pic"
android:orientation="vertical">
<TextView
android:id="@+id/tv_commodity_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="酒红色纯红色纯羊毛西服套装"
android:textColor="@color/black"
android:textStyle="bold" />
<RelativeLayout
android:id="@+id/rl_edit"
android:layout_width="110dp"
android:layout_height="30dp"
android:orientation="horizontal"
android:visibility="gone">
<ImageView
android:id="@+id/iv_sub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/iv_sub" />
<TextView
android:id="@+id/tv_show_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="1"
android:textColor="@color/desccolor" />
<ImageView
android:id="@+id/iv_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@mipmap/iv_add" />
<View
android:layout_width="match_parent"
android:layout_height="0.7dp"
android:layout_alignParentBottom="true"
android:background="@color/black" />
</RelativeLayout>
<TextView
android:id="@+id/tv_fabric"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="面料:"
android:textColor="@color/gray5" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_dress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="西服尺寸: 48"
android:textColor="@color/gray5" />
</LinearLayout>
<TextView
android:id="@+id/tv_pants"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="西裤尺寸: 68"
android:textColor="@color/gray5" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="¥390"
android:textColor="@color/black"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:text="x1"
android:textColor="@color/gray5" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/tv_delete"
android:layout_width="60dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:background="@color/address_press"
android:gravity="center"
android:text="删除"
android:visibility="gone" />
</RelativeLayout>
layout_title:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/maintab_text"
android:orientation="vertical">
<Button
android:id="@+id/btn_back"
android:layout_width="50dp"
android:layout_height="match_parent"
android:background="@null"
android:text="返回"
android:textColor="@color/white"
android:visibility="gone" />
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="@color/white"
android:textSize="20dp" />
<TextView
android:id="@+id/tv_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:text="登录"
android:textColor="@color/white"
android:textSize="15dp"
android:visibility="gone" />
</RelativeLayout>