微信主界面

    

    我们布局应该从局来看,如上图,我们可以分为三个大的LinearLayout,再从LinearLayout嵌套其它布局,从而做出界面

  文件

      

    主界面代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<!-- 头部 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<include layout="@layout/top"/><!--引用其它布局-->
</LinearLayout> <!-- 中间 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
</LinearLayout> <!-- 底部 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<include layout="@layout/buttonr"/><!--引用其它布局-->
</LinearLayout>
</LinearLayout>

    为了代码的维护和简洁,我们可以引用其它的布局,如上图, <include layout="@layout/buttonr"/>引用已经完成的布局

  顶部

    我们添加一个LinearLayout布局的文件

      

        

  顶部界面

        

    这个布局我们可以用一个大的LinearLayout再嵌套一个小LinearLayout

  代码     

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#21292c"//背景色
android:orientation="horizontal" > <TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="22sp"//字体大小
android:textColor="#FFFFFF"//字体颜色
android:padding="10dp"
android:text="@string/app_name" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center" > <ImageView
android:id="@+id/imageView2"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginRight="10dp"
//图片
android:src="@drawable/fdj" /> <ImageView
android:id="@+id/imageView1"
android:layout_width="30dp"
android:layout_height="30dp"
//图片
android:src="@drawable/barbuttonicon_add" />
</LinearLayout> </LinearLayout>

  底部界面:如上所示添加LinearLayout布局文件,会涉及到一个控件的运用RadioGroup控件

    

    

  RadioButton和RadioGroup的关系:

    1、RadioButton表示单个圆形单选框,而RadioGroup是可以容纳多个RadioButton的容器

    2、每个RadioGroup中的RadioButton同时只能有一个被选中

    3、不同的RadioGroup中的RadioButton互不相干,即如果组A中有一个选中了,组B中依然可以有一个被选中

    4、大部分场合下,一个RadioGroup中至少有2个RadioButton

    5、大部分场合下,一个RadioGroup中的RadioButton默认会有一个被选中,并建议您将它放在RadioGroup中的起始位置

  主要代码  

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" > <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"//水平
android:layout_alignParentTop="true"
>
<RadioGroup android:orientation="horizontal"//水平
android:layout_width="match_parent" android:layout_height="wrap_content">
<RadioButton
android:layout_width="0dp"
android:layout_weight="1"//权重
android:layout_height="wrap_content"
android:drawableTop="@drawable/four"//引用外部文件
android:checked="true"
android:text="@string/xiao"
style="@style/text"
android:button="@null"//去掉前面的圆点
android:gravity="center"//居中
/>
<RadioButton
android:layout_width="0dp"
android:layout_weight="1"//权重
android:layout_height="wrap_content"
android:drawableTop="@drawable/tuo"//引用外部文件
android:text="@string/tong"
style="@style/text"
android:button="@null"//去掉前面的圆点
android:gravity="center"//居中
/>
<RadioButton
android:layout_width="0dp"
android:layout_weight="1"//权重
android:layout_height="wrap_content"
android:drawableTop="@drawable/three"//引用外部文件
android:text="@string/ss"
style="@style/text"
android:button="@null"//去掉前面的圆点
android:gravity="center"//居中
/>
<RadioButton
android:layout_width="0dp"
android:layout_weight="1"//权重
android:layout_height="wrap_content"
android:drawableTop="@drawable/one"//引用外部文件
android:text="@string/wo"
style="@style/text"
android:button="@null"//去掉前面的圆点
android:gravity="center"//居中
/>
</RadioGroup>
</LinearLayout>
</RelativeLayout>

    添加外部文件

      

      

  外部文件内容:添加四个这样的文件,分别对应四张图片,如果选中的的话,图片会变动

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_checked="true"//选中是tabbar_mehl这个图片
android:drawable="@drawable/tabbar_mehl"></item>
<item
//没有选中是tabbar_me图片
android:drawable="@drawable/tabbar_me"></item>
</selector>

  添加字体变色的文件,如上添加

  颜色文件代码 

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_checked="true"
android:color="@color/green"></item>
<item
android:color="@color/grey"></item> </selector>

  添加外部样式

  

   字体颜色

      

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="grey">#999999</color>
<color name="green">#07bb07</color>
</resources>

 

  <style name="text">
<item name="android:textColor">@drawable/text</item>
</style>

  底部就做好了

  在主界面布局分别引用这些分布局,界面就做好了。我们应该多多实践,多看下关于属性的书和资料.

 

android开发--布局三(微信布局)的更多相关文章

  1. .Net程序猿玩转Android开发---(3)登陆页面布局

    这一节我们来看看登陆页面如何布局.对于刚接触到Android开发的童鞋来说.Android的布局感觉比較棘手.须要结合各种属性进行设置,接下来我们由点入面来 了解安卓中页面如何布局,登陆页面非常eas ...

  2. .Net程序猿乐Android开发---(4)注册页面布局

    接下来我们介绍的登陆页面布局,在本节中,我们看一下注册页面布局,页面布局大同小异,来一起熟悉下基本控件的使用方法. 效果图: 1.加入注冊页面 右键选中layout目录,加入注冊页面.例如以下图 点击 ...

  3. android 开发 写一个RecyclerView布局的聊天室,并且添加RecyclerView的点击事件

    实现思维顺序: 1.首先我们需要准备2张.9的png图片(一张图片为左边聊天泡泡,一个图片为右边的聊天泡泡),可以使用draw9patch.bat工具制作,任何图片导入到drawable中. 2.需要 ...

  4. android开发 RecyclerView 瀑布列表布局

    1.写一个内容的自定义小布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xm ...

  5. android学习笔记三--Activity 布局

    1.线性布局 标签 :<LinearLayout></LinearLayout> 方向:android:orientation, 垂直:vertical 水平:Horizont ...

  6. CSS布局 - 三栏布局

    CSS布局技术可谓是前端技术中最基础的技术,就是因为基础,所以我认为要更加熟练,深入的去掌握,去梳理. 一. 传统 ---> 浮动实现的三栏布局 采用浮动实现的三栏布局有以下特点及注意事项: · ...

  7. 简单的CSS网页布局--三列布局

    三列布局其实不难,不过要用到position:absolute这个属性,因为这个属性是基于浏览器而言,左右部分各放在左右侧,空出中间一列来实现三列布局. (一)三列布局自适应 <!DOCTYPE ...

  8. Android 开发中三种多线程

    在开发工程中线程可以帮助我们提高运行速度,Android开发中我知道的线程有四个一个是老生长谈的Thread,第二个是asyncTask,第三个:TimetTask,第四个是Looper,四个多线程各 ...

  9. CSS布局——三栏布局

    说到三栏布局,很多都会提到圣杯布局和双飞翼布局这两个经典的三栏布局方式.于是,我在网上搜了一些相关资料,阅读并跟着代码敲了一遍,发现在处理三栏布局上,他们采用的都是两边栏固定,中间栏自适应的策略.在处 ...

随机推荐

  1. excel具有制作甘特图的功能

    1.Excel最大功能:数据处理.统计分析. 2.数据有效性验证: 长数字输入方法,文本前面加英文"'"(单引号)或使用文本转换. 身份证号:数据.数据有效性.文本长度. 性别:数 ...

  2. iOS-Xcode7 网络连接

    Xcode7 网络无法连接问题 1.The resource could not be loaded because the App Transport Security policy require ...

  3. Java笔记6-数组

    知识大纲一.数组的应用由于数组是用来存储数据的,所以,它的操作总是增.删除.改.查的操作.数组做为一种最基本的数据结构,它在查询上效率是最高的.但是在增加.删除的操作效率是最低的. 因为,数组的长度一 ...

  4. java中的抽象类和接口

    抽象类和接口本身让面向对象真正实现,一个好的系统可以让抽象类或者接口实现多次复用,如果出现了集成具体类那么肯定是有问题的. 抽象类和接口很相似,很多时候好像功能可以混用,java设计者赋予了很多不一样 ...

  5. java json-lib.jar

    import java.util.ArrayList; import java.util.Date; import java.util.List; import net.sf.json.JSONObj ...

  6. JS特殊函数(Function()构造函数、函数直接量)区别介绍

    函数定义 函数是由这样的方式进行声明的:关键字 function.函数名.一组参数,以及置于括号中的待执行代码. 函数的构造语法有这三种: 1.function functionName(arg0, ...

  7. python之类的属性

    class type(object) With one argument, return the type of an object. The return value is a type objec ...

  8. Spring MVC入门实战(一)

    本文主要把一个菜鸟从“只是听说过Spring MVC”到“可以手动创建并运行一个Spring MVC工程”的过程记录下来,供以后复习. 0. 开发环境准备 计算机平台:Windows 7 X64. 需 ...

  9. hbase shell基础和常用命令详解(转)

    HBase shell的基本用法 hbase提供了一个shell的终端给用户交互.使用命令hbase shell进入命令界面.通过执行 help可以看到命令的帮助信息. 以网上的一个学生成绩表的例子来 ...

  10. CSS基本语法

    这里主要介绍Bootstrap里用到的CSS语法,以便在源码分析时更容易理解和学习.Bootstrap的CSS组件的核心就是选择器的定义以及在各自优先级上的处理. 优先级 如何确定CSS的优先级,这里 ...