xml布局内容总结(四)--Android
(1)对于xml编写界面较复杂的情况下,使用include会使得编写和查看更清楚
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<include android:id="@+id/hi1" layout="@layout/health_info1" />
<include android:id="@+id/hi2" layout="@layout/health_info2" />
<include android:id="@+id/hi3" layout="@layout/health_info3" />
<include android:id="@+id/hi4" layout="@layout/health_info4" />
<include android:id="@+id/hi5" layout="@layout/health_info5" />
</LinearLayout>
这里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中的使用方法
<com.jxj.view.BigDialView
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框架中看到了这样的使用方法比較简单,用一条语句替换了
<RelativeLayout
android:id="@+id/top_head"
style="@style/w_full_h_wrap"
android:background="@drawable/head_back"
android:orientation="horizontal" >
等同于
<RelativeLayout
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
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 全屏幕拉伸 -->
<style name="w_h_full">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item>
</style>
<!-- 高度和屏幕高度一样 宽度自适应 -->
<style name="w_wrap_h_full">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">fill_parent</item>
</style>
<!-- 宽度和屏幕宽度一样 高度自适应 -->
<style name="w_full_h_wrap">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
</style>
<!-- 固定自身大小 -->
<style name="w_wrap_h_wrap">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
</style>
</resources>
xml布局内容总结(四)--Android的更多相关文章
- xml布局内容总结(一)--Android
关于安卓项目中xml的使用非常多.为了达到一些好的UI效果.须要对xml比較熟练.会使用非常多的小技巧,本人准备对这些小技巧进行整理和总结,希望进行分享和交流. 关于weight的使用,因为weigh ...
- xml布局内容总结(三)--Android
关于xml中经经常使用到边框及边框效果,在此进行一下总结. 3.border(边框及边框效果) (1)直角边框线 <LinearLayout android:layout_wid ...
- 通过在xml布局文件中设置android:onClick=""来实现组件单击事件
在布局中出现android:onClick=""语句: <Button android:id="@+id/call_button" android:onC ...
- android xml布局文件属性说明
android xml布局文件属性说明 [摘]android xml布局文件属性说明 LinearLayout和RelativeLayout 共有属性:java代码中通过btn1关联次控件androi ...
- 20165205 2017-2018-2 《Java程序设计》实验四 Android程序设计
20165205 2017-2018-2 <Java程序设计>实验四 Android程序设计 实验内容 实验四 Android程序设计-1 Android Stuidio的安装测试: 参考 ...
- 20155314 2016-2017-2 《Java程序设计》实验四 Android程序设计
20155314 2016-2017-2 <Java程序设计>实验四 Android程序设计 实验任务 基于Android Studio开发简单的Android应用并部署测试 了解Andr ...
- android 开发 使用自定义布局实现标题栏复用(标题栏内容自定义:使用代码实现和xml布局自定义属性2种办法实现)
在个人学习的情况下可能很少使用自定义布局去实现大量复用的情况下,但是在一个开发工作的环境下就会使用到大量复用的自定义控件. 实现思维: 1.写一个xml的布局,用于标题栏的样式,并且添加在标题栏中你想 ...
- Android中将xml布局文件转化为View树的过程分析(下)-- LayoutInflater源码分析
在Android开发中为了inflate一个布局文件,大体有2种方式,如下所示: // 1. get a instance of LayoutInflater, then do whatever yo ...
- 仿酷狗音乐播放器开发日志二十四 选项设置窗体的实现(附328行xml布局源码)
转载请说明原出处,谢谢~~ 花了两天时间把仿酷狗的选项设置窗体做出来了,当然了只是做了外观.现在开学了,写代码的时间减少,所以整个仿酷狗的工程开发速度减慢了.今天把仿酷狗的选项设置窗体的布局代码分享出 ...
随机推荐
- Spring MVC中 提交表单报错400
背景: 在写SpringMVC表单提交的代码的时,在最后点击提交的时候总是会出现400的错误 原因: 主要原因就是表单提交的数据和对应实体类的属性无法完全匹配 解决方案: 查看我们提交的数据是否完全和 ...
- Ubuntu下使用crontab部署定时任务
Ubuntu下使用crontab部署定时任务 安装cron apt-get install cron 开启crontab日志 默认情况下的日志是没有开启的,我们需要找到 /etc/rsyslog.d/ ...
- [using_microsoft_infopath_2010]Chapter6 发布提交表单数据
本章概要: 1.使用正确的方法发布表单 2.发布表单画库到SharePoint 3.在发布和保存表单之间做出选择 4.理解不同发布表单方式之间的区别
- [ReactVR] Start a Virtual Reality Project Using the React VR CLI
We will learn how to set up a React VR project, run the development mode with hot reloading, and tak ...
- tensorflow入门教程和底层机制简单解说——本质就是图计算,自动寻找依赖,想想spark机制就明白了
简介 本章的目的是让你了解和运行 TensorFlow! 在开始之前, 让我们先看一段使用 Python API 撰写的 TensorFlow 示例代码, 让你对将要学习的内容有初步的印象. 这段很短 ...
- oracle 11g RAC 的一些基本概念
一.脑裂以及对策 脑裂(split-brain)是集群中的一个糟糕的情况:集群中的所有集群正在工作的时候,内部通讯被断开.这种情况下,集群被分成了几个部分,每个部分的集群软件都会尝试去接管其他节点的资 ...
- OC冒泡排序算法
面试的时候很多公司会要求写一个冒泡排序算法,于是用OC写了一个,代码如下所示 需要注意的事项:oc数组只能存放oc对象,因此遍历数组输出的时候,记得通过NSString对象转换成intValue #i ...
- linux批处理笔记
最近不得不用到Linux批处理,于是把要用到的程序反复研究了一下. #!/bin/bash是指此脚本使用/bin/bash来解释执行. -le -ge分别是小于和大于,这个倒是和latex里面的命令很 ...
- 51nod 1562 玻璃切割 (STL map+一点点的思考)
1562 玻璃切割 题目来源: CodeForces 基准时间限制:1.5 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 现在有一块玻璃,是长方形的(w 毫米× h 毫米),现在要 ...
- 前端学习之路——gulp篇
一.构建gulp环境 1.下载nodejs gulp基于node.js,要通过nodejs的npm安装gulp,所以要先安装node.js环境.(英文官网/中文官网链接). 通过cmd命令窗口确定安装 ...