Question

I have a problem, when I run my Android App on the emulator, I can fine see my Spinner, but when I run it on my phone it's hard to see the spinner.

enter image description here

I tried to cut out some color, to see if there is anything in the spinner, but no :( It just show a number but I can fine press the number and it shows the content of my Spinner , but I want to see the background of my Spinner

MainActivity.java

final String[] plHand = getResources().getStringArray(R.array.yourHand_array);
final String[] dlHand = getResources().getStringArray(R.array.dealerHand_array);    

final Spinner sp1 = (Spinner) findViewById(R.id.spinPlayer);
final Spinner sp2 = (Spinner) findViewById(R.id.spinDealer);

final ArrayAdapter<String> ar1 = new ArrayAdapter<String>(this,
        android.R.layout.simple_spinner_item, plHand);
final ArrayAdapter<String> ar2 = new ArrayAdapter<String>(this,
    android.R.layout.simple_spinner_item, dlHand);

sp1.setAdapter(ar1);
sp2.setAdapter(ar2);

My XML

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.black.jack.rechner.MainActivity"
android:background="@drawable/table"
tools:ignore="MergeRootFrame" >

<Spinner
    android:id="@+id/spinPlayer"
    android:layout_width="128dp"
    android:layout_height="wrap_content"
    android:layout_gravity="top"
    android:textColor="#FFFF00"
    android:layout_marginTop="20dp" />

<Spinner
    android:id="@+id/spinDealer"
    android:layout_width="110dp"
    android:textColor = "#000000"
    android:layout_height="wrap_content"
    android:layout_gravity="right"
    android:layout_marginTop="20dp" />

I tried to change the Textcolor but with no luck, hope you can spot the tiny mistake I made.(Don't worry about the design it's a beta :P)

Was it helpful?

Solution

The styling of components like that can vary from device to device. So, if you want it to stay the same on all devices you can specify a background for it. Something like;

<Spinner
android:id="@+id/spinPlayer"
android:layout_width="128dp"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#FFFFFF"
android:layout_marginTop="20dp" />

The example above will make the background entirely white. If you want a more robust background like the one you linked in some comments, then you'll need to create an image file, store it in your drawable folder and refer to it like so;

android:background="@drawable\your_spinner_background_image"

OTHER TIPS

Seems you need to style it correctly. Now it uses the phone theme whats probably not matching the rest of the color scheme in your application. For a guide styling the spinner see the following website:

http://adanware.blogspot.in/2012/03/android-custom-spinner-with-custom.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top