Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to align text in Spinner for android?

I want to align text in Spinner to the left but how can i achieve this require help

here is my code & screen shot

 <TableLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:background="@drawable/roundshape" >

        <!-- Lable Area -->

        <TableRow
            android:id="@+id/tblRwspnLbl"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"           
            android:gravity="center" 
            android:padding="1dip">

            <TextView
                android:id="@+id/lblCust"
                android:layout_width="80dp"
                android:layout_height="wrap_content"
                android:text="@string/lblCust"
                android:textSize="14sp"
                android:textStyle="bold" 
                android:gravity="left"/>

            <TextView
                android:id="@+id/lblPros"
                android:layout_width="80dp"
                android:layout_height="wrap_content"
                android:text="@string/lblPros"
                android:textSize="14sp"
                android:textStyle="bold" />
        </TableRow>

        <!-- Spinner Area -->

        <TableRow
            android:id="@+id/tblRwspn"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="1dip"                
            android:gravity="center" >

            <Spinner
                android:id="@+id/spnAECust"
                android:layout_width="75dp"
                android:layout_height="35dp"
                android:fontFamily="verdana,arial,helvetica"
                android:hint="@string/SelectCust"
                android:textSize="14sp" 
                android:layout_gravity="left"/>

            <Spinner
                android:id="@+id/spnAEProspect"
                android:layout_width="75dp"
                android:layout_height="35dp"
                android:fontFamily="verdana,arial,helvetica"
                android:hint="@string/SelectProspect"
                android:textSize="14sp" />
        </TableRow>

        <!-- Text Area -->

Here is my Screen the red dot is the space which i want to remove so tht my all labels and spinners will come in same aligned line

enter image description here

like image 770
Aditi K Avatar asked Dec 31 '13 06:12

Aditi K


1 Answers

Just remove android:padding="1dip" from Spinner TableRow and try i am not sure just try

Edit: You have to use a custom view here to give alignment to the Spinner values. Create a CustomView like this answer has created and add android:gravity' to the TextView asright`.

And set the CustomView to your adapter using

adapter.setDropDownViewResource(android.R.layout.your_custom_created_view);
like image 110
M D Avatar answered Sep 19 '22 20:09

M D