how to align fields in android? -


enter image description here hi making simple example in android problem textview , editfield not align.it mean should

![name               editview rollnumber         editview               button on center][2] 

it this

here code

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"    android:orientation="vertical"      android:layout_width="fill_parent"      android:layout_height="fill_parent"    >    <linearlayout       android:orientation="horizontal"      android:layout_width="fill_parent"      android:layout_height="wrap_content"            >   <textview          android:id="@+id/text_view_boat1"         android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:text="name"        />      <edittext          android:id="@+id/entry"          android:hint="add name"          android:layout_width="wrap_content"          android:layout_height="wrap_content"      />       </linearlayout>     <linearlayout              android:orientation="horizontal"      android:layout_width="fill_parent"      android:layout_height="wrap_content"           >     <textview          android:id="@+id/text_view_boat2"         android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:text="roll number" />      <edittext          android:id="@+id/entry2"          android:hint="add roll number"          android:layout_width="wrap_content"          android:layout_height="wrap_content"     />          </linearlayout>        <button          android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="click me"         android:id="@+id/clickme"             /> </linearlayout> 

use tablelayout instead :

    <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"         xmlns:tools="http://schemas.android.com/tools"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:orientation="vertical" >              <tablelayout                 android:layout_width="fill_parent"                 android:layout_height="wrap_content"                 android:paddingtop="10dp"                 android:shrinkcolumns="1"                 android:stretchcolumns="1" >                  <tablerow                     android:descendantfocusability="beforedescendants"                     android:focusable="true"                     android:focusableintouchmode="true" >                      <textview                         android:layout_width="wrap_content"                         android:layout_height="wrap_content"                         android:text="name  :" />                      <edittext                         android:id="@+id/companyidedittext_id"                         android:layout_width="wrap_content"                         android:layout_height="wrap_content"                         android:text=""                          android:enabled="false"/>                 </tablerow>                  <tablerow                     android:descendantfocusability="beforedescendants"                     android:focusable="true"                     android:focusableintouchmode="true" >                      <textview                         android:layout_width="wrap_content"                         android:layout_height="wrap_content"                         android:text="rollnumber  :" />                      <edittext                         android:id="@+id/companynameedittext_id"                         android:layout_width="wrap_content"                         android:layout_height="wrap_content"                         android:text="" />                 </tablerow>     </tablelayout>  <button                  android:layout_height="wrap_content"                 android:layout_width="wrap_content"                 android:text="clickme"/>     </linearlayout> 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -