购物车布局

主布局

<RelativeLayout
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.bwie.month_demo.view.ShopcartActivity">
    <ScrollView
        android:layout_above="@+id/relative_progress"
        android:layout_width="match_parent"
        android:layout_alignParentTop="true"
        android:layout_height="match_parent">
        <com.bwie.month_demo.view.custom.CartExpanableListview
            android:id="@+id/expanable_listview"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"></com.bwie.month_demo.view.custom.CartExpanableListview>
    </ScrollView>

    <RelativeLayout
        android:visibility="gone"
        android:id="@+id/relative_progress"
        android:layout_above="@+id/line"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ProgressBar
            android:layout_width="60dp"
            android:layout_height="60dp"
           android:layout_centerInParent="true" />

    </RelativeLayout>
    <LinearLayout
        android:id="@+id/line"
        android:layout_alignParentBottom="true"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="50dp">
        <CheckBox
            android:layout_marginLeft="10dp"
            android:button="@null"
            android:background="@drawable/check_box_selector"
            android:id="@+id/check_all"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/text_total"
            android:text="合计:¥0.00"
            android:layout_weight="2"
            android:layout_width="0dp"
            android:layout_height="wrap_content" />

        <TextView
            android:text="去结算(0)"
            android:background="#ff0000"
            android:textColor="#ffffff"
            android:gravity="center"
            android:id="@+id/text_buy"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent" />
    </LinearLayout>
</RelativeLayout>

子布局

<LinearLayout
    android:orientation="horizontal"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:padding="10dp"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:id="@+id/rel"
        android:layout_toLeftOf="@+id/text_delete"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <CheckBox
            android:layout_centerVertical="true"
            android:id="@+id/check_child"
            android:button="@null"
            android:background="@drawable/check_box_selector"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <ImageView
            android:id="@+id/image_good"
            android:layout_centerVertical="true"
            android:layout_toRightOf="@+id/check_child"
            android:layout_marginLeft="10dp"
            android:layout_width="80dp"
            android:layout_height="80dp" />

        <TextView
            android:id="@+id/text_title"
            android:layout_toRightOf="@+id/image_good"
            android:layout_marginLeft="10dp"
            android:layout_alignTop="@+id/image_good"
            android:maxLines="2"
            android:minLines="2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/text_price"
            android:layout_toRightOf="@+id/image_good"
            android:layout_marginLeft="10dp"
            android:layout_alignBottom="@+id/image_good"
            android:text="¥99.99"
            android:textColor="#ff0000"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <LinearLayout
            android:layout_alignParentRight="true"
            android:layout_alignBottom="@+id/image_good"
            android:orientation="horizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

            <TextView
                android:id="@+id/text_jian"
                android:text="一"
                android:padding="5dp"
                android:background="@drawable/bian_kuang_line"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <TextView
                android:gravity="center"
                android:id="@+id/text_num"
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
                android:background="@drawable/bian_kuang_line"
                android:layout_width="wrap_content"
                android:layout_height="match_parent" />

            <TextView
                android:id="@+id/text_add"
                android:text="十"
                android:padding="5dp"
                android:background="@drawable/bian_kuang_line"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

        </LinearLayout>

    </RelativeLayout>

    <TextView
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="3dp"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@+id/rel"
        android:layout_alignBottom="@+id/rel"
        android:id="@+id/text_delete"
        android:background="#ff0000"
        android:text="删除"
        android:gravity="center"
        android:textColor="#ffffff"
        android:layout_width="50dp"
        android:layout_height="match_parent" />


</LinearLayout>

全选布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:gravity="center_vertical"
    android:padding="10dp"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <CheckBox
        android:button="@null"
        android:background="@drawable/check_box_selector"
        android:id="@+id/check_group"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TextView
        android:layout_marginLeft="10dp"
        android:text="京东自营"
        android:id="@+id/text_group"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</LinearLayout>

自定义布局

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_checked="true" android:drawable="@drawable/shopping_cart_checked"/>
    <item android:state_checked="false" android:drawable="@drawable/shopping_cart_none_check"/>
    <item android:drawable="@drawable/shopping_cart_none_check"/>
</selector>

自定义边框布局

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#ffffff" />

    <stroke
        android:width="0.1dp"
        android:color="#000000" />

</shape>

自定义二级列表

public class CartExpanableListview extends ExpandableListView {

    public CartExpanableListview(Context context) {
        super(context);
    }

    public CartExpanableListview(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CartExpanableListview(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int height = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE>>2,MeasureSpec.AT_MOST);

        super.onMeasure(widthMeasureSpec, height);
    }

}























  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
基于Tensorflow、OpenAI搭建的强化学习框架,训练机器自动操盘 强化学习(Reinforcement Learning, RL),又称再励学习、评价学习或增强学习,是机器学习的范式和方法论之一。它主要用于描述和解决智能体(agent)在与环境的交互过程中通过学习策略以达成回报最大化或实现特定目标的问题。强化学习的特点在于没有监督数据,只有奖励信号。 强化学习的常见模型是标准的马尔可夫决策过程(Markov Decision Process, MDP)。按给定条件,强化学习可分为基于模式的强化学习(model-based RL)和无模式强化学习(model-free RL),以及主动强化学习(active RL)和被动强化学习(passive RL)。强化学习的变体包括逆向强化学习、阶层强化学习和部分可观测系统的强化学习。求解强化学习问题所使用的算法可分为策略搜索算法和值函数(value function)算法两类。 强化学习理论受到行为主义心理学启发,侧重在线学习并试图在探索-利用(exploration-exploitation)间保持平衡。不同于监督学习和非监督学习,强化学习不要求预先给定任何数据,而是通过接收环境对动作的奖励(反馈)获得学习信息并更新模型参数。强化学习问题在信息论、博弈论、自动控制等领域有得到讨论,被用于解释有限理性条件下的平衡态、设计推荐系统和机器人交互系统。一些复杂的强化学习算法在一定程度上具备解决复杂问题的通用智能,可以在围棋和电子游戏中达到人类水平。 强化学习在工程领域的应用也相当广泛。例如,Facebook提出了开源强化学习平台Horizon,该平台利用强化学习来优化大规模生产系统。在医疗保健领域,RL系统能够为患者提供治疗策略,该系统能够利用以往的经验找到最优的策略,而无需生物系统的数学模型等先验信息,这使得基于RL的系统具有更广泛的适用性。 总的来说,强化学习是一种通过智能体与环境交互,以最大化累积奖励为目标的学习过程。它在许多领域都展现出了强大的应用潜力。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值