有没有简单的方法来创建这些步进按钮?
Is there any easy way to create these stepper buttons?
我需要像图像中的月份和年份按钮这样的按钮。名为 Ystepperview 的库可用于 ios,但未找到用于 android 的库。如果有人实现了此类按钮,请告诉我创建此视图的简单方法是什么。
XML:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="55dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="@drawable/your_shape"
android:orientation="horizontal"
android:weightSum="2">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:gravity="center"
android:padding="15dp"
android:src="@drawable/yourLeftIcon"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="0"
android:background="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:background="#fbae41"
android:gravity="center"
android:text="JAN"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="@color/white"
android:textSize="18sp" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="0"
android:background="#000000" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:gravity="center"
android:padding="15dp"
android:src="@drawable/yourRightIcon"
/>
</LinearLayout>
形状 your_shape.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#999a97"/>
<stroke android:width="1dip" android:color="#000000" />
<corners android:radius="24dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
输出:
将角 android:radius="24dip" 更改为正确的半径,背景颜色为纯色 [=30=]="#999a97",您将获得示例视图。
我需要像图像中的月份和年份按钮这样的按钮。名为 Ystepperview 的库可用于 ios,但未找到用于 android 的库。如果有人实现了此类按钮,请告诉我创建此视图的简单方法是什么。
XML:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="55dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="@drawable/your_shape"
android:orientation="horizontal"
android:weightSum="2">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:gravity="center"
android:padding="15dp"
android:src="@drawable/yourLeftIcon"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="0"
android:background="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:background="#fbae41"
android:gravity="center"
android:text="JAN"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="@color/white"
android:textSize="18sp" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_weight="0"
android:background="#000000" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:gravity="center"
android:padding="15dp"
android:src="@drawable/yourRightIcon"
/>
</LinearLayout>
形状 your_shape.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#999a97"/>
<stroke android:width="1dip" android:color="#000000" />
<corners android:radius="24dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
输出:
将角 android:radius="24dip" 更改为正确的半径,背景颜色为纯色 [=30=]="#999a97",您将获得示例视图。