2013-08-24 31 views
3

我正在使用NumberPicker并显示String的值。这里是例子:如何使NumberPicker文本区域变宽?

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

odaberiRazinu.setDisplayedValues(new String[] { "FirstAnswer", "SecondAnswer", "ThirdAnswer", "FourthAnswer"}); 

我有问题,因为从FirstAnswer,只有它是唯一可见的“stAnsw”(类似的东西)。当我移动它时,它有时会变宽,但效果不好。

有没有办法让显示区域更宽或者是否有更好的方法来制作-like机制Strings

EDIT(这是XML布局):

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

回答

1

此代码对我的作品。 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> 

enter image description here

您也可以设置一个静态widht android:layout_width="300dp"但随后将截断文本IFI是更长的时间。