Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何使NumberPicker文本区域更宽?_Android_Numberpicker - Fatal编程技术网

Android 如何使NumberPicker文本区域更宽?

Android 如何使NumberPicker文本区域更宽?,android,numberpicker,Android,Numberpicker,我正在使用NumberPicker并显示String值。以下是一个例子: odaberiRazinu.setVisibility(View.VISIBLE); odaberiRazinu.setMinValue(0); odaberiRazinu.setMaxValue(3); odaberiRazinu.setDisplayedValues( new String[] { "FirstAnswer", "SecondAnswer", "ThirdAnswer", "FourthAnswer"

我正在使用
NumberPicker
并显示
String
值。以下是一个例子:

odaberiRazinu.setVisibility(View.VISIBLE);
odaberiRazinu.setMinValue(0);
odaberiRazinu.setMaxValue(3);

odaberiRazinu.setDisplayedValues( new String[] { "FirstAnswer", "SecondAnswer", "ThirdAnswer", "FourthAnswer"} );
我有一些问题,因为从FirstAnswer开始,只有“stAnsw”(类似的东西)才可见。当我移动它时,它有时会变得更宽,但它工作不好

有没有办法使显示区域更宽,或者有没有更好的办法使
NumberPicker
类似于
字符串的机制

编辑(这是XML布局):


这个代码对我很有用。NumberPicker与最长的项目文本一样宽。也许您必须为父布局选择不同的大小

<FrameLayout
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <NumberPicker
        android:id="@+id/section_numberPicker"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />

</FrameLayout>

您还可以设置一个静态widt
android:layout\u width=“300dp”
,但如果文本更长,它将截断文本

<FrameLayout
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <NumberPicker
        android:id="@+id/section_numberPicker"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />

</FrameLayout>