【学习笔记】Android常用布局

发布时间:2020-07-23 18:48:37 作者:wx57a1620925627
来源:网络 阅读:332


一、LinearLayout线性布局

(1)线性布局分为垂直和水平两个方向

     android:orientation="vertical"
     android:orientation="horizontal"

(2)定义宽和高

     铺满父级容器:match_parent
     根据内容自适应:wrap_content
     android:layout_width=""
     android:layout_height=""

(3)设置权重

      android:layout_weight="1"  全部

二、RelativityLayout相对布局

   

    //新建并设置一个RelativityLayout布局

     RelativityLayout root=new RelativityLayout(this);

    setContentView(root);

    

    //添加一个textView控件

     TextView tv=new TextView(this);

    tv.setText("hello");

    

    //定义RelativityLayout参数,有两个参数高和宽

    RelativityLayout.LayoutParams lp=new RelativityLayout.LayoutParams(RelativityLayout.LayoutParams.WrapContent,RelativityLayout.LayoutParams.WrapContent);

    root.addView(tv,lp);


三、 FrameLayout


用的比较少,加进来的控件自动堆叠在一起。日后再补充

推荐阅读:
  1. Xamarin 学习笔记 - Layout(布局)
  2. 【入门篇】Android学习笔记——常用布局

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

布局 android roi

上一篇:第九章   缓存技术

下一篇:if示例2_shell脚本

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》