hi i want to create a a layout which must have an EditText and a Sibmit B开发者_Python百科utton 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
i m 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.
精彩评论