简体   繁体   中英

need help in android layouts

hi i want to create aa layout which must have an EditText and a Sibmit Button in a top of the screen and They should horizontally aligned and filled the whole horizontal space.

whenever i go to portrait or landscape mode it should fill the whole horizontal space. Please guide. m stucked at this point in my application

Thanks

you can try this :

 <RelativeLayout android:layout_width="fill_parent" 
    android:layout_height="fill_parent" >
  <Button android:id="@+id/btnSubmit" android:layout_width="wrap_content"
          android:text="Submit"
          android:layout_height="wrap_content" android:layout_alignParentTop="true"
          android:layout_alignParentRight = "true" android:padding = "4dp" />

  <EditText android:id="@+id/txtEdit" android:layout_width="fill_parent" 
          android:layout_toLeftOf="@id/btnSubmit"
          android:layout_height="wrap_content" android:layout_alignTop="@id/btnSubmit"
          android:layout_alignBottom = "@id/btnSubmit" android:padding = "4dp" />

 </RelativeLayout>

hope it helps :)

Note :take a look on this link , it's very helpful for you ;) Understanding User Interface in Android

Checkout this link

Take help from this and customize it according to your need.

im done with that adding a weight= 1 did my work.

<LinearLayout android:id="@+id/rl1" android:orientation="horizontal" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:layout_below="@+id/message" >

<EditText android:id="@+id/search_bar" android:singleLine="true" android:hint="Search"
    android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content"></EditText>
<Button android:id="@+id/search_submit" android:layout_height="wrap_content" android:layout_width="wrap_content"
    android:layout_alignParentRight="true" android:text="Search"></Button>
</LinearLayout>

this works great.. Please vote this answer so that others can also take help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM