android xml 层级_xml布局内容总结(四)--Android

(1)对于xml编写界面较复杂的情况下,使用include会使得编写和查看更清楚

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical"

>

这里health_info1到health_info5是5个布局文件,相应于界面中的5个模块,每一个模块单独200行左右,假设在单独的模块中,不论是改动还是查看都比較easy,假设不适用include,整个布局文件就是1000行左右。无论是改动还是查看都比較麻烦,类似于代码中函数的调用。

CheckBox  hiCbPs1;

hiCbPs1=(CheckBox)findViewById(R.id.hi1).findViewById(R.id.hicbps1);

这是代码中的使用方法

(2)自己定义view的使用。在开发产品时,有时候会碰到一些须要自己进行绘制的view增加到界面中

加入到到xml中的使用方法

android:id="@+id/healthstatedial"

android:layout_width="fill_parent"

android:layout_height="200dip"

android:layout_margin="5dip"

android:layout_gravity="center"

android:scaleType="centerInside"

/>

com.jxj.view  是包名   BigDialView是自己定义的类名   com.jxj.view.BigDialView是完整的路径

这里常常easy出错的问题就是xml中找不到该类,原因通常是未定义这个类,还是就是包名或类名写错导致xml找不到

(3)这个是在LoonAndroid框架中看到的。认为挺好用

基本全部的控件都会用到这两条语句

android:layout_width="fill_parent"

android:layout_height="wrap_content"

在LoonAndroid框架中看到了这样的使用方法比較简单,用一条语句替换了

android:id="@+id/top_head"

style="@style/w_full_h_wrap"

android:background="@drawable/head_back"

android:orientation="horizontal" >

等同于

android:id="@+id/top_head"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:background="@drawable/head_back"

android:orientation="horizontal" >

想要使用这样的方法。仅仅需在values文件夹下加入

themes_basic.xml

fill_parent

fill_parent

wrap_content

fill_parent

fill_parent

wrap_content

wrap_content

wrap_content

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值