Use Relativelayout to control the location (address) of the webview and bottom buttons
In Design view, add the control relativelayout, WebView, linearlayout (horizontal), button, button.
- Add new layout-
WebViewLayout.axml
opens the file. Select the default LinearLayout and delete.
- Add Relativelayout, drag the Relativelayout control to the page in Toolbox.
- Drag the WebView control into the relativelayout.
- Drag linearlayout (horizontal) into relativelayout and place under WebView.
- Drag two buttons to linearlayout (horizontal).
After completing the above steps, the page source code is as follows:
<?xml version= "1.0" encoding= "Utf-8"? ><relativelayout xmlns:p1= "http://schemas.android.com/apk/res/ Android "P1:layout_width=" Match_parent "p1:layout_height=" match_parent "p1:id=" @+id/relativelayout1 "> <W Ebview p1:layout_width= "wrap_content" p1:layout_height= "wrap_content" p1:id= "@+id/webview1"/> <linearlayout p1:orientation= "Horizontal" p1:minwidth= "25px" p1:minheight= "25px" P1:layout_ Width= "Wrap_content" p1:layout_height= "wrap_content" p1:layout_below= "@id/webview1" p1:id= "@+id/linea RLAYOUT1 "> <button p1:text=" button "p1:layout_width=" Wrap_content "p1:layout _height= "Match_parent" p1:id= "@+id/button2"/> <button p1:text= "button" p1:l Ayout_width= "Wrap_content" p1:layout_height= "match_parent" p1:id= "@+id/button1"/> </Linear Layout></relativelayout>
Switch to source View for the following modifications:
In WebView, add the Location attribute.
p1:layout_above="@+id/linearLayout1"
Modify the WebView Layout_width, Layout_height property is fill_parent
.
p1:layout_width="fill_parent"p1:layout_height="fill_parent"
Adds a LinearLayout layout_alignParentBottom
property.
p1:layout_alignParentBottom="true"
Modify the LinearLayout layout_width, Layout_height property.
p1:layout_width="match_parent"p1:layout_height="wrap_content"
In order to divide the two buttons into spaces, add layout_weight
attributes.
p1:layout_weight="0.5"
The modified source code is as follows:
<?xml version= "1.0" encoding= "Utf-8"?> <relativelayout xmlns:p1= "http://schemas.android.com/apk/res/ Android "P1:layout_width=" Match_parent "p1:layout_height=" match_parent "p1:id=" @+id/relativelayout1 "> <webview p1:layout_width= "fill_parent" p1:layout_height= "fill_parent" p1:id= "@+id/webview 1 "p1:layout_above=" @+id/linearlayout1 "/> <linearlayout p1:orientation=" Horizontal " P1:minwidth= "25px" p1:minheight= "25px" p1:layout_width= "match_parent" p1:layout_height= "Wrap_c Ontent "p1:layout_below=" @id/webview1 "p1:id=" @+id/linearlayout1 "p1:layout_alignparentbottom=" True "> <button p1:text=" button "p1:layout_width=" Wrap_content "P1:la yout_height= "Match_parent" p1:id= "@+id/button2" p1:layout_weight= "0.5"/> <button p1:text= "button" P1:layout_width= "Wrap_content" p1:layout_height= "match_parent" p1:id= "@+id/button1" p1:layout_weight= "0.5"/> </LinearLayout> </RelativeLayout>
Use Relativelayout to control the position of the webview and bottom buttons