0

I have created an activity with spinner control and I want to style it.

XML :

<Spinner
  android:id="@+id/spin_inch"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:layout_weight="1"
  android:popupBackground="@color/orange"
  android:textColor="@color/black" />

Java :

spin_inch = (Spinner) findViewById(R.id.spin_inch);
ArrayAdapter<CharSequence> adapter_inch= ArrayAdapter.createFromResource(this, R.array.inch_array, android.R.layout.simple_spinner_item);
adapter_inch.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

Could someone please let me know how to remove this extra border?

I am a Student
  • 1,570
  • 4
  • 21
  • 36
virajs
  • 43
  • 1
  • 4

2 Answers2

0

Try using match_parent on layout_width

     <Spinner
     android:id="@+id/spin_inch"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_weight="1"
     android:popupBackground="@color/orange"
     android:textColor="@color/black" />
Tekkiller
  • 1
  • 2
  • 1
    Please edit your answer and add some context by explaining how your answer solve the problem in question, instead of posting code-only answer. – Pedram Parsian Dec 25 '19 at 05:07
-1

The problem is with your layout_width and layout-height properties in XML.

Change them to wrap_content both

<Spinner
  android:id="@+id/spin_inch"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_weight="1"
  android:popupBackground="@color/orange"
  android:textColor="@color/black" />

You've used layout_weight also, so if you've applied weightSum in parent of Spinner, apply 0dp to respective property in Spinner. For example, if your Orientation is Horizontal with weightSum applied, you should apply 0dp in layout_width in Spinner. Else, if your Orientation is Vertical with weightSum applied, you should apply 0dp in layout_height in Spinner.

Kushal
  • 8,100
  • 9
  • 63
  • 82