when i select long text in my spinner
then its create space between textView
and spinner
see my default spinner
:
after selecting a long text it's look like below shot:
below is xml code :
<TextView
style="@style/TextLabelBookGray"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/hint_state"
android:textSize="@dimen/_14ssp"
android:paddingLeft="@dimen/_2sdp"
android:visibility="visible" />
<android.support.v7.widget.AppCompatSpinner
android:id="@+id/spStates"
style="@style/TextLabelBookBlack"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginBottom="@dimen/_4sdp"
android:layout_marginTop="@dimen/_4sdp"
android:layout_weight="1"
android:entries="@array/us_states"
/>
below code is style.xml
:
<style name="TextLabelBookGray" parent="FontBook">
<item name="android:textSize">@dimen/_14ssp</item>
<item name="android:textColor">@color/input_color_gray</item>
any one have any idea how to i fix it
Thanks in advance :
You set spinner height as "wrap_content" so it will automatically adjust its height.You should set Spinner row's Textview max line as 1.Then it will not show double line. Textview xml file
android:maxLines="1"
Adding to @Kush answer, Please make sure that your parent also having wrap_content so that your spinner text can show in one line. Otherwise, It will look same even if you give wrap_content to your spinner.
Please use below code:
<android.support.v7.widget.AppCompatSpinner
android:id="@+id/spStates"
style="@style/TextLabelBookBlack"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginBottom="@dimen/_4sdp"
android:layout_marginTop="@dimen/_4sdp"
android:layout_weight="1"
android:maxLines="1"
android:entries="@array/us_states"
/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With