java 在水平模式下创建一个数字选择器,android:orientation="horizo​​ntal" 工作了吗?我试过了,但数字选择器在垂直模式下仍然相同

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34118359/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 22:30:18  来源:igfitidea点击:

Create a number picker in horizontal mode, did android:orientation="horizontal" work? I have try but the number picker still same in vertical mode

javaandroidandroid-layoutandroid-number-picker

提问by Wg Sam

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 ?

我想在水平模式下创建一个数字选择器,但我设置了 android:orientation="horizo​​ntal",它仍然无法工作。我怎样才能像下面的图片一样在水平模式下创建数字选择器?

enter image description here

在此处输入图片说明

<?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>

回答by

NumberPickerdoes not support horizontal orientation. So you have to write your own or use one of few existed libraries:

NumberPicker不支持水平方向。因此,您必须自己编写或使用少数现有库之一:

  1. HorizontalPicker
  2. android-spinnerwheel
  1. 水平选择器
  2. android-spinnerwheel