5

I have a NumberPicker, where i want to return 2 lines instead of singleline. so far i have tried to use \n and created a custom style for NumberPicker.

style.xml

    <style name="AppTheme.Picker" parent="AppTheme.Picker" >
    <item name="android:textColorPrimary">@android:color/white</item>
    <item name="android:textSize">12dp</item>
    <item name="android:maxLines">2</item>
    <item name="android:singleLine">false</item>
</style>

my main_acivity.xml file

    <NumberPicker
    android:theme="@style/AppTheme.Picker"
    android:id="@+id/card_options"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
</NumberPicker>

and the activity class

public class CardOptions extends Activity {

NumberPicker cardOptions;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);

    cardOptions = (NumberPicker) findViewById(R.id.card_options);

    cardOptions.setMinValue(1);
    cardOptions.setMaxValue(2);
    cardOptions.setDisplayedValues(new String[]{"red\nblue", "green\nYellow"});

}

}

Can anyone help with this?

user993074
  • 93
  • 6

0 Answers0