Spinner on white

0

I have two Spinners in a fragmentLayout , both work but I can not see them in the fragmentLayout , they appear in white.

p>

This is the fragment:

This is a Spinner that you can not see:

Fragment XML:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="55dp"
    android:background="#ffff">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="top|center"
        android:orientation="vertical">

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="top|center">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_alignParentTop="true"
                android:gravity="center"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/textView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true"
                    android:layout_centerHorizontal="true"
                    android:layout_marginTop="10dp"
                    android:gravity="center"
                    android:text="@string/str_img"
                    android:textColor="@color/com_facebook_messenger_blue"
                    android:textSize="25sp"
                    android:textStyle="bold" />

                <ImageView
                    android:id="@+id/imagemId"
                    android:layout_width="150dp"
                    android:layout_height="113dp"
                    android:layout_alignParentTop="true"
                    android:layout_centerHorizontal="true"
                    android:layout_marginTop="2dp"
                    android:src="@drawable/logomarktxt" />

                <Button
                    android:id="@+id/btnCargarImg"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"

                    android:layout_alignParentBottom="true"
                    android:background="#ffff"
                    android:onClick="onclick"
                    android:text="@string/select_img"
                    android:textColor="@color/blue_sky" />

                <Space
                    android:layout_width="match_parent"
                    android:layout_height="3dp" />

                <EditText
                    android:id="@+id/locationnametxt"
                    android:layout_width="280dp"
                    android:layout_height="40dp"
                    android:layout_marginLeft="30dp"
                    android:layout_marginRight="30dp"
                    android:layout_marginTop="10dp"
                    android:background="#ffff"
                    android:ems="10"
                    android:hint="Name of Loaction"
                    android:inputType="textPersonName"
                    android:textColor="@color/com_facebook_button_background_color_focused_disabled"
                    android:textColorHint="@android:color/darker_gray" />


                <Space
                    android:layout_width="match_parent"
                    android:layout_height="6dp" />

                <Spinner
                    android:id="@+id/spinnerzone"
                    android:layout_width="280dp"
                    android:layout_height="40dp"
                    android:layout_marginLeft="30dp"
                    android:layout_marginRight="30dp"
                    android:layout_marginTop="10dp"
                    android:alwaysDrawnWithCache="false" />


                <Space
                    android:layout_width="match_parent"
                    android:layout_height="6dp" />


                <Spinner
                    android:id="@+id/spinnercategory"
                    android:layout_width="280dp"
                    android:layout_height="40dp"
                    android:layout_marginBottom="10dp"
                    android:layout_marginLeft="30dp"
                    android:layout_marginRight="30dp"
                    android:layout_marginTop="10dp"
                    />


            </LinearLayout>
        </ScrollView>

    </LinearLayout>

</android.support.constraint.ConstraintLayout>

Java code:

 void spinnerhint(List<String>arrayList,Spinner spinner){
        spinnerArrayAdapter = new ArrayAdapter<String>(
                this.getActivity(),android.R.layout.simple_spinner_item,arrayList){
            @Override
            public boolean isEnabled(int position){
                if(position == 0)
                {
                    // Disable the first item from Spinner
                    // First item will be use for hint
                    return false;
                }
                else
                {
                    return true;
                }
            }
            @Override
            public View getDropDownView(int position, View convertView,
                                        ViewGroup parent) {
                View view = super.getDropDownView(position, convertView, parent);
                TextView tv = (TextView) view;
                if(position == 0){
                    // Set the hint text color gray
                    tv.setTextColor(Color.GRAY);
                }
                else {
                    tv.setTextColor(Color.BLACK);
                }
                return view;
            }
        };
        spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
        spinner.setAdapter(spinnerArrayAdapter);

    }

How do I get to see them and also change the black color they have when they open?

    
asked by Julio Mizrahi 04.09.2018 в 21:57
source

1 answer

0

Hello, you must create this xml first.

fondo.xml

''

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
          <item android:state_pressed="true"
                android:drawable="#f2f2f2" />
          <item android:drawable="#f2f2f2" />
</selector>

Then in the spiner put this attribute

android:background="@drawable/fondo"
    
answered by 05.09.2018 / 15:26
source