Ali :
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 :
Zayid Mohammed :
The thing is that your textView and spinner shares 50% and 50% of parent view. Better you set weightSum to parent view and allocate more width to spinner. Then you can have one line text in spinner.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="10">
<TextView
style="@style/TextLabelBookGray"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="2.5"
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="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginBottom="@dimen/_4sdp"
android:layout_marginTop="@dimen/_4sdp"
android:layout_weight="7.5"
android:entries="@array/us_states"/>
</LinearLayout>
This is a working example and adjust the weight according to your need.
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=437001&siteId=1