Skip to content

用来实现类似购物车里数量加减的一个控制器,按钮背景均使用shape绘制,可根据项目自定义颜色

Notifications You must be signed in to change notification settings

vsloong/AddSubController

Repository files navigation

说明

类似购物车的一种数量加减的控制器,具体见效果图:

主要使用两个Button和一个TextView来实现效果, 按钮背景依靠layer-list和shap的属性来绘制圆角矩形, 具体代码见drawable文件夹:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_centerInParent="true"
    android:gravity="center"
    android:orientation="horizontal">

    <Button
        android:id="@+id/btn_subtract"
        android:layout_width="50dp"
        android:layout_height="match_parent"
        android:background="@drawable/selecter_left"
        android:gravity="center"
        android:text="-"
        android:textColor="@android:color/white"
        android:textSize="32sp" />

    <TextView
        android:id="@+id/text_number"
        android:layout_width="100dp"
        android:layout_height="match_parent"
        android:background="#F1F1F1"
        android:gravity="center"
        android:text=""
        android:textSize="20sp"/>

    <Button
        android:id="@+id/btn_add"
        android:layout_width="50dp"
        android:layout_height="match_parent"
        android:background="@drawable/selecter_right"
        android:text="+"
        android:textColor="@android:color/white"
        android:textSize="20sp" />
</LinearLayout>

About

用来实现类似购物车里数量加减的一个控制器,按钮背景均使用shape绘制,可根据项目自定义颜色

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages