Reputation: 1067
this is my original number picker which it display in vertical.
i want to make it display in horizontal where it will display the buttons left and right instead of up and down. but it does not work. it still looks like vertical.
this is my code.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_picker);
String[] nums = new String[21];
for(int i=0; i<nums.length; i++)
nums[i] = Integer.toString(i*5);
NumberPicker np = (NumberPicker) findViewById(R.id.np);
np.setMaxValue(nums.length-1);
np.setMinValue(0);
np.setWrapSelectorWheel(false);
np.setDisplayedValues(nums);
this is my code for np.xml
<NumberPicker
android:id="@+id/np"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:width="100dip" />
Upvotes: 1
Views: 11526
Reputation: 1308
I was searching for the same and found a library that seems helpful check this on github Number Picker
Upvotes: 0
Reputation: 2021
As far as I know there is no way to adapt a NumberPicker to horizontal orientation. You should probably check this out:
or this:
although these two libraries seem to be obsolete and not maintained; in that case I would suggest to create a custom horizontal picker or to use an alternative Input Control
.
Upvotes: 3
Reputation: 9730
NumberPicker
does not support a horizontal orientation. To accomplish this you probably need to create a custom implementation.
Upvotes: 4