问题
I want to create a number picker in horizontal mode, but i set the android:orientation="horizontal", it still cannot work. How can i create the number picker in horizontal mode just like the pic below ?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.sam.weighttrack.KeyInWeightF">
<LinearLayout
android:id="@+id/payment2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<NumberPicker
android:id="@+id/numberPicker1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" />
</LinearLayout>
</RelativeLayout>
回答1:
NumberPicker
does not support horizontal orientation. So you have to write your own or use one of few existed libraries:
- HorizontalPicker
- android-spinnerwheel
来源:https://stackoverflow.com/questions/34118359/create-a-number-picker-in-horizontal-mode-did-androidorientation-horizontal