使用RelativeLayout控制WebView以及Bottom按钮的位置 (地址

在Design View中加入控件RelativeLayout, WebView, LinearLayout(Horizontal), Button, Button

  1. 添加新Layout - WebViewLayout.axml, 打开文件。 选中默认的LinearLayout并删除。
  2. 添加RelativeLayout, 在Toolbox中拖动RelativeLayout控件到页面中。
  3. 拖动WebView控件到RelativeLayout中。
  4. 拖动LinearLayout(Horizontal)到RelativeLayout中, 置于WebView之下。
  5. 拖动两个Button到LinearLayout(Horizontal)中。

完成以上步骤以后,页面源代码如下:

<?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="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/linearLayout1">
<Button
p1:text="Button"
p1:layout_width="wrap_content"
p1:layout_height="match_parent"
p1:id="@+id/button2" />
<Button
p1:text="Button"
p1:layout_width="wrap_content"
p1:layout_height="match_parent"
p1:id="@+id/button1" />
</LinearLayout>
</RelativeLayout>

切换到Source View, 实现如下修改:

  1. 在WebView中,加入位置属性。

    p1:layout_above="@+id/linearLayout1"
  2. 修改WebView的layout_width, layout_height属性为fill_parent

    p1:layout_width="fill_parent"
    p1:layout_height="fill_parent"
  3. 添加LinearLayout的layout_alignParentBottom属性。

    p1:layout_alignParentBottom="true"
  4. 修改LinearLayout的layout_width, layout_height属性。

    p1:layout_width="match_parent"
    p1:layout_height="wrap_content"
  5. 为了使两个Button平分空间, 加入layout_weight属性。

    p1:layout_weight="0.5"

修改后的源代码如下:

  <?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/webView1"
p1:layout_above="@+id/linearLayout1" />
<LinearLayout
p1:orientation="horizontal"
p1:minWidth="25px"
p1:minHeight="25px"
p1:layout_width="match_parent"
p1:layout_height="wrap_content"
p1:layout_below="@id/webView1"
p1:id="@+id/linearLayout1"
p1:layout_alignParentBottom="true">
<Button
p1:text="Button"
p1:layout_width="wrap_content"
p1:layout_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>

使用RelativeLayout控制WebView以及Bottom按钮的位置的更多相关文章

  1. AppBoxPro - 细粒度通用权限管理框架(可控制表格行内按钮)源码提供下载

    特别声明: 提供的源代码已经包含了 AppBoxPro 的全部源代码,用 VS2012 打开项目后,直接 Ctrl+F5 可以运行起来(默认使用VS自带的LocalDB数据库). FineUIPro是 ...

  2. elementUI 的el-dialog作为子组件,父组件如何控制其关闭的按钮

    这里有三点需要说明: 1. 使用:before-close="closeHandle" 将其 $emit() 出去 2. 取消按钮 也需要$emeit出去 3. 控制对话框显示隐藏 ...

  3. scroll与按钮的位置

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. jQuery实现两个按钮的位置互换

    页面上有2个按钮A和B.点击按钮A和按钮B互换位置 ,点击按钮B和按钮A互换位置.应该如何实现? html代码如下: <body> <!--页面上有2个按钮A和B. 点击按钮A和按钮 ...

  5. 控制图片在latex中的位置

    如何做到自己控制图片在latex中的位置? 方法:在 \begin{figure} 后面加参数 [h!] 即 \begin{figure}[h!] % Requires \usepackage{gra ...

  6. Dynamic CRM 2013学习笔记(十八)根据主表状态用JS控制子表自定义按钮

    有时要根据主表的审批状态来控制子表上的按钮要不要显示,比如我们有一个需求审批通过后就不能再上传文件了. 首先打开Visual Ribbon Editor, 如下图,我们可以利用Enable Rules ...

  7. android webview重定向 返回按钮死循环问题修改

    当HTML有重定向的时候,回退时会不断往跳转进入死循环.尝试修改webview缓存加载策略以后,不起作用.在网上查阅资料以后,跟 shouldOverrideUrlLoading的返回值为true还是 ...

  8. Android--用JS去控制WebView显示的字体的大小

    <script type="text/javascript"> function changeFontSize(size) { var tfs = '120%'; va ...

  9. js控制“鼠标点击按钮后,按钮消失“(可以自己添加video标签控制播放)

随机推荐

  1. json序列化时datetime的处理方法

    .net自带的json序列化器,JavaScriptSerializer和DataContractJsonSerializer,都是序列化成微软的datetime json格式,e.g. " ...

  2. Yes, Virginia, Scala is hard

    首先要说的是,我是一个Scala粉丝,我作为一个Scala语言的倡导者差不多有5年历史了.我写了不少Scala语言方面的书和文章.我曾在数十个公司里做过Scala和Lift框架项目的开发.我对很多的S ...

  3. Objective-C_基本数据类型详解

    今天在工作群里面看到有人在发面试题求帮解答,顺便看了一眼,发现一个很侮辱程序员的面试题,但是自己也答得不是很好,所以特意上网查了一下资料,废话不说,附原题: “常见的Objective-C的数据类型有 ...

  4. 项目中常用的linux命令

    1. du -sm * | sort -n 把当前目录下的文件(或目录)按大小排序,看下哪个地方占用最多: 2. pwd                     获取当前目录路径 3. tail -f ...

  5. Retrofit源码研究

    2016-05-06 15:35:27 最近抽空研究了一下Retrofit源码,包括API使用.源码结构.使用到的设计模式.SDK的架构设计.作者设计/实现思路等,会形成一系列文章. 以前Retrof ...

  6. 编程key note

    一些日常发现的code better的要点.不断更新. * #include <assert.h> 使用断言* 每个模块(文件)应该有一个唯一的一个前缀,模块导出的所有全局名字都应以此前缀 ...

  7. java培训第一天--画板

    package day1; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt ...

  8. golang调用EXE

    我是win7+go1.7+liteide,调用calc.exe package main import ( "os/exec" ) func main() { datapath : ...

  9. Qt中2D绘图问题总结(二)----------坐标系统

    坐标系统 使用QPainter绘制时使用到逻辑坐标,然后转换成绘图设备的物理坐标. 逻辑坐标到物理坐标的映射由QPainter的worldTransform()函数.QPainter的viewport ...

  10. ado.net中,数据的批量处理

    //btBigImport按钮点击事件 private void btBigImport_Click(object sender, RoutedEventArgs e)        { //连接字符 ...