Create a number picker in horizontal mode, did android:orientation=“horizontal” work? I have try but the number picker still same in vertical mode [duplicate]

坚强是说给别人听的谎言 提交于 2019-12-19 11:16:20

问题


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:

  1. HorizontalPicker
  2. android-spinnerwheel


来源:https://stackoverflow.com/questions/34118359/create-a-number-picker-in-horizontal-mode-did-androidorientation-horizontal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!