How Can One Align Spinners Right To Left?
Can anyone tell me what do I do wrong? :( I have 2 Spinners and two TextViews that I want to align right. I have set everything to right but still everything is left aligned. Her
Solution 1:
You made a mistake while adding the drawable on the radiobutton..Try this and lemme know
android:drawableLeft="@android:drawable/btn_radio"
Solution 2:
Use
android:layout_toRightOf="@id/textView_from"
android:layout_toRightOf="@id/textView_to"
this may help you
Solution 3:
The reason is this :
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"android:layout_gravity="right"
**android:gravity="right">**
You set the top layout to align everything to the right side, so your inner layout, which is set to wrap_content
doesn't take all the space available and so gets aligned right. So either remove the android:gravity
from the outer layout, OR set your inner layouts layout_width
to match_parent
.
Update, as it didn't work : Replace your inner linear layout with this : (I had to change string resources, but you'll figure out)...
<LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:weightSum="2" ><LinearLayoutandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:orientation="horizontal" ><TextViewandroid:id="@+id/textView_from"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="From" /><Spinnerandroid:id="@+id/spinner1"android:layout_width="match_parent"android:layout_height="wrap_content"android:background="@android:drawable/btn_dropdown"android:spinnerMode="dropdown" /></LinearLayout><LinearLayoutandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:orientation="horizontal" ><TextViewandroid:id="@+id/textView_to"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="To" /><Spinnerandroid:id="@+id/spinner2"android:layout_width="match_parent"android:layout_height="wrap_content"android:background="@android:drawable/btn_dropdown"android:spinnerMode="dropdown" /></LinearLayout></LinearLayout>
Post a Comment for "How Can One Align Spinners Right To Left?"