您可以通过使用两个
numberpicker
s并排放置来实现类似的定制:
<linearlayout xmlns:android=“http://schemas.android.com/apk/res/android”
android:layout_width=“匹配父级”
android:layout_height=“匹配父级”
android:gravity=“中心”
android:orientation=“水平”>
<数字选取器
android:id=“@+id/第一个号码”
android:layout_width=“包装内容”
android:layout_height=“包装内容”
android:theme=“@style/customNumberPickerTheme”/>
文本视图
android:layout_width=“包装内容”
android:layout_height=“包装内容”
安卓:text=“”
android:textsize=“24sp”/>
<数字选取器
android:id=“@+id/秒\号码”
android:layout_width=“包装内容”
android:layout_height=“包装内容”
android:theme=“@style/customNumberPickerTheme”/>
</linearlayout>
< /代码>
为了更好地匹配屏幕截图,Atextviewwas included in between the twonumberpickers as the decimal point with a custom themecustomnumberpickerTheme.which you'll need to set insideres/values/styles.xml.
资源
…
<style name=“CustomNumberPickerTheme”parent=“AppTheme”>
<item name=“colorcontrolNormal”>@android:color/transparent</item>
&风格/风格;
</resources>
< /代码>
您可以通过使用两个NumberPicker
S并排放置:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal">
<NumberPicker
android:id="@+id/first_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:theme="@style/CustomNumberPickerTheme" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="."
android:textSize="24sp" />
<NumberPicker
android:id="@+id/second_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:theme="@style/CustomNumberPickerTheme" />
</LinearLayout>
为了更好地匹配屏幕截图ATextView
包括在两人之间数字选择器
s作为小数点和自定义主题CustomNumberPickerTheme
你需要把它放在里面res/values/styles.xml
<resources>
...
<style name="CustomNumberPickerTheme" parent="AppTheme">
<item name="colorControlNormal">@android:color/transparent</item>
</style>
</resources>