Use Relativelayout to control the position of the webview and bottom buttons

Source: Internet
Author: User

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.

    1. Add new layout- WebViewLayout.axml opens the file. Select the default LinearLayout and delete.
    2. Add Relativelayout, drag the Relativelayout control to the page in Toolbox.
    3. Drag the WebView control into the relativelayout.
    4. Drag linearlayout (horizontal) into relativelayout and place under WebView.
    5. 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:

    1. In WebView, add the Location attribute.

      p1:layout_above="@+id/linearLayout1"
    2. Modify the WebView Layout_width, Layout_height property is fill_parent .

      p1:layout_width="fill_parent"p1:layout_height="fill_parent"
    3. Adds a LinearLayout layout_alignParentBottom property.

      p1:layout_alignParentBottom="true"
    4. Modify the LinearLayout layout_width, Layout_height property.

      p1:layout_width="match_parent"p1:layout_height="wrap_content"
    5. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.