jdponce
jdponce

Reputation: 51

Font color in Ti.UI.createPicker

I tried to set the font color to black and I can't, I would appreciate your help with this:

Ti.UI.backgroundColor = 'white';
var win = Ti.UI.createWindow({
  backgroundColor : "#ffffff",
  exitOnClose: true,
  layout: 'vertical'
});

var picker = Ti.UI.createPicker({
    borderWidth : 1,
    borderColor : "gray",
    color : "black",
    borderRadius : 5,
    width : "90%",
  top:50
});

var data = [];
data[0]=Ti.UI.createPickerRow({title:'El Salvador'});
data[1]=Ti.UI.createPickerRow({title:'Guatemala'});
data[2]=Ti.UI.createPickerRow({title:'Honduras'});
data[3]=Ti.UI.createPickerRow({title:'Nicaragua'});
data[4]=Ti.UI.createPickerRow({title:'Costa Rica'});

picker.add(data);
picker.selectionIndicator = true;

win.add(picker);
win.open();

// must be after picker has been displayed picker.setSelectedRow(0, 2, false);

Upvotes: 1

Views: 471

Answers (3)

Mark Boyer
Mark Boyer

Reputation: 209

If you're trying to implement the enhancements that came out as part of 5.2, the docs say you can only change the color if the picker is a type of time or datetime. https://jira.appcelerator.org/browse/TIMOB-16547

But Abada's method of using the label works fine.

Upvotes: 2

Venkatesh
Venkatesh

Reputation: 209

Create themes.xml in /platform/android/res/values/themes.xml

<resources>
<style name="LightTheme" parent="@style/Theme.AppCompat.Light">
   <item name="android:spinnerDropDownItemStyle">@style/mySpinnerItemStyle</item>
   <item name="android:spinnerItemStyle">@style/mySpinnerItem</item>
</style>

<style name="mySpinnerItemStyle" parent="@android:style/Widget.Holo.DropDownItem.Spinner">
    <item name="android:textColor">#000</item>
    <item name="android:background">#d0d0d0</item>
</style>
<style name="mySpinnerItem" parent="@android:style/Widget.TextView.SpinnerItem">
    <item name="android:textColor">#000</item>
</style>
</resources>

Upvotes: 2

abada henno
abada henno

Reputation: 740

You can use Label tag inside PickerRow

<Picker  >
         <PickerColumn id="column1">
              <PickerRow   >
                <Label   color="#0000"    > Blah Blah </Label>
              </PickerRow>
             </PickerColumn> 

</Picker>

Upvotes: 3

Related Questions