Android Left,Center and Right Alignment -


i pretty new android , trying sample app 3 elements (2 buttons , 1 text view ) placed horizontally. need text in center 2 buttons aligned left , right of view.

e.g.

|<button>    <text>     <button>| 

appreciate if me this.

thanks in advance

edit: believe solve problem. see below code. let me know if helps! know has helped me , using it. accept answer if worked! =)

<?xml version="1.0" encoding="utf-8"?> <tablelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:stretchcolumns="1">     <tablerow>         <button              android:layout_width="wrap_content"             android:layout_height="wrap_content"              android:text="button1"              android:id="@+id/button1button"></button>         <edittext              android:layout_height="wrap_content"              android:id="@+id/firstedittext"             android:layout_width="wrap_content"></edittext>         <button              android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:text="button2"              android:id="@+id/button2button"></button>     </tablerow> </tablelayout> 

edit: added relative layout see if works you, let me know if works. need adjust "10px" desired distance. seeing if there better way this, distance more dynamic.

you can make buttons "alignparentleft" , "alignparentright" them align right , left side of screen. however, still having trouble getting text between 2 views.

you in xml file layout. make horozontal layout , add first button first, text view, second button. post xml shortly example.

    <relativelayout          android:id="@+id/linearlayout01"         android:orientation="horizontal"          android:layout_width="fill_parent"         android:layout_height="wrap_content">         <button              android:layout_width="wrap_content"             android:layout_height="wrap_content"              android:text="button1"              android:layout_alignparentleft="true"             android:layout_marginright="10px"             android:id="@+id/button1button"></button>         <edittext              android:layout_height="wrap_content"              android:id="@+id/firstedittext"             android:layout_torightof="@id/button1button"             android:layout_marginright="10px"             android:layout_width="wrap_content"></edittext>         <button              android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_torightof="@id/firstedittext"             android:text="button2"              android:id="@+id/button2button"></button>     </relativelayout> 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -