一、准备工作:

1、 下载好相关的图片:

2、创建一个名WeiChat的项目,将图片复制到res-----》drawable-hdpi目录下。

二、编写代码:

1、 最终效果:

2、微信可划分为头、中间、尾三部分,最后我们将这三部分合并在同一界面。

①头部:headlayout

headlayout.xml文件:

<?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:orientation="horizontal"
android:background="#21292c" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/weixin"
android:textColor="#ffffff"
android:textSize="20sp"
android:layout_gravity="center"
android:padding="10dp"/>
<TextView
android:layout_width="wrap_content"
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="40dp"
android:layout_height="30dp"
android:src="@drawable/fdj"
android:layout_marginRight="10dp"/> <ImageView
android:id="@+id/imageView1"
android:layout_width="40dp"
android:layout_height="30dp"
android:src="@drawable/barbuttonicon_add" /> </LinearLayout> </LinearLayout>

1、通过LinearLayout布局,设置android:orientation="horizontal",android:background="#21292c"两个属性显示背景为灰黑色。

2 、我们通过两个TextView控件来显示“微信” 和字体与右边图片隔离,通过两个ImageView控件显示最右边的两张图片,有LinearLayout布局水平方向让图片对齐。

3、通过gravity属性设置图片在LinearLayout居中,设置ImageView的layout_marginRight设置两张图片不相连。

效果图:

②尾部:footlayout

footlayout.xml文件:

<?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="match_parent"
android:orientation="vertical" > <RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:background="@drawable/group_buton_nomal"
android:gravity="center">
<RadioButton
android:id="@+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="@string/weixin"
style="@style/radioStyle"
android:drawableTop="@drawable/weicho1"/>
<RadioButton
android:id="@+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/addressList"
style="@style/radioStyle"
android:drawableTop="@drawable/weicho2"/>
<RadioButton
android:id="@+id/radio2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/find"
style="@style/radioStyle"
android:drawableTop="@drawable/weicho3"/> <RadioButton
android:id="@+id/radio3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/set"
style="@style/radioStyle"
android:drawableTop="@drawable/weicho4"/>
</RadioGroup>
</LinearLayout>

1、通过四个RadioButton单选控件来显示下面四张图片,drawableTop属性设置图片,通过styles。xml文件设置样式。

① 设置值为@null将去掉空心圆,设置每个RadioButton控件的layout_weight="1"位权为1,平分位置。

styles.xml文件:

<style name="radioStyle">
<item name="android:button">@null</item>
<item name="android:layout_weight">1</item>
<item name="android:gravity">center</item>
<item name="android:textColor">@drawable/choscolor</item>
</style>

2、点击变色:点击图标时图标和文字变为绿色,而其他的则为浅灰色。RadioButton有个checked点击属性。

3、我们添加了五个selector类型的xml文件,分别命名为weicho1到weicho4,最后一命名为choscolor.xml文件(用来设置字体颜色)。

4、当checked=true时就设置drawable属性为绿色图片,通过styles.xml文件的radioStyle设置字体颜色为绿色。(注:其他3个xml文件与weicho1.xml文件一样只是图片名称不一样)

weicho1.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_checked="true"
//绿色图片
android:drawable="@drawable/tabbar_mainframehl"></item>
<item
android:drawable="@drawable/tabbar_mainframe"></item>
</selector>

choscolor.xml文件:

<?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>

效果图片:

③中间:listviewon1

listviewon1.xml文件:

<?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="match_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="match_parent" > </ListView> </LinearLayout>

1、我们通过一个ListView实现动态添加数据,现在我们就站一个位置,不这么快添加数据。(注见下一章listview动态添加数据篇)。

④合并头、中间、尾三部分:weichatlayout

weichatlayout.xml文件:

<?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="match_parent"
android:orientation="vertical" >
<!-- head -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<include layout="@layout/headlayout"/>
</LinearLayout> <!-- 中间 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<include layout="@layout/listviewon1"/>
</LinearLayout> <!-- 底部 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<include layout="@layout/footlayout"/>
</LinearLayout> </LinearLayout>

1、我们通过3个LinearLayout布局设置头,中,尾。

2、通过layout_weight="1"设置中的位权占满剩余的空间,固定头和尾的大小。

3、通过include的layout属性设置相关的布局 。

效果图片:

Android之微信布局篇的更多相关文章

  1. android 安卓 微信布局 [1]

    微信布局 直接上代码吧 ---------------------------------------- 头部 -------------------------------------------- ...

  2. Android开发--微信布局(ListView)基本运用

    ListView 1.ListVeiw 用来展示列表的View. 2.适配器 用来把数据映射到ListView上的中介. 3.数据    具体的将被映射的字符串,图片,或者基本组件. 根据列表的适配器 ...

  3. Android视图篇之一:Android常见基本布局

    Android中,布局都是直接或间接的继承自ViewGroup类,其中,ViewGroup的直接子类目前有: AbsoluteLayout, AdapterView<T extends Adap ...

  4. 【详细】Android入门到放弃篇-YES OR NO-》各种UI组件,布局管理器,单元Activity

    问:达叔,你放弃了吗? 答:不,放弃是不可能的,丢了Android,你会心疼吗?如果别人把你丢掉,你是痛苦呢?还是痛苦呢?~ 引导语 有人说,爱上一个人是痛苦的,有人说,喜欢一个人是幸福的. 人与人之 ...

  5. Android UI-仿微信底部导航栏布局

    现在App基本的标配除了侧滑菜单,还有一个就是底部导航栏,常见的聊天工具QQ,微信,购物App都有底部导航栏,用户可以随便切换看不同的内容,说是情怀也好,用户体验也罢.我们开发的主要的还是讲的是如何如 ...

  6. 使用wepy开发微信小程序商城第三篇:购物车(布局篇)

    使用wepy开发微信小程序商城 第三篇:购物车(布局篇) 前两篇如下: 使用wepy开发微信小程序商城第一篇:项目初始化 使用wepy开发微信小程序商城第二篇:路由配置和页面结构 基于上两篇内容,开始 ...

  7. Android开发之五大布局篇

    一.Android中常用的5大布局方式有以下几种: 线性布局(LinearLayout):按照垂直或者水平方向布局的组件. 相对布局(RelativeLayout):相对其它组件的布局方式. 绝对布局 ...

  8. Android仿微信图片上传,可以选择多张图片,缩放预览,拍照上传等

    仿照微信,朋友圈分享图片功能 .可以进行图片的多张选择,拍照添加图片,以及进行图片的预览,预览时可以进行缩放,并且可以删除选中状态的图片 .很不错的源码,大家有需要可以下载看看 . 微信 微信 微信 ...

  9. Android FoldingLayout 折叠布局 原理及实现(二)

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/44283093,本文出自:[张鸿洋的博客] 1.概述 在上一篇Android Fo ...

随机推荐

  1. python __init__.py 的作用

    __init__.py的主要作用是: . Python中package的标识,不能删除 . 定义__all__用来模糊导入 . 编写Python代码(不建议在__init__中写python模块,可以 ...

  2. MQTT简介

    MQTT简介 MQTT是IBM开发的一个即时通讯协议,该协议支持所有的平台,几乎可以把所有联网的物品和外部连接起来,被用来当做传感器和致动器(比如通过Twitter让房屋联网)的通信协议 MQTT的特 ...

  3. python中模块包的离线下载教程

    1.简介 当我们进行Python项目的迁移时(例如迁移到另外一台服务器上),如果该服务器要求离线安装, 往往需要我们将项目中的所需模块包进行离线操作. 2.教程 2.1 首先安装pip2pi模块,它可 ...

  4. zabbix3.4.7利用Windows性能监视器监控各项资源指标

    zabbix自带的windows监控模板并没有监控windows cpu使用率的监控 在cmd命令的窗口输入perfmon,就会弹出一下界面 点击性能监视器 点击如图加号,出现很多参数 选择proce ...

  5. UVa 11134 - Fabled Rooks 优先队列,贪心 难度: 0

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  6. 关于django的一些基础知识

    1.中间件 中间件的作用 : 在全局范围内控制django的输入和输出的钩子函数 中间件中有5种方法: process_request : 请求进来时,进行验证 process_views : 路由匹 ...

  7. 【Java集合系列三】Vector-Stack解析

    2017-07-29 12:59:14 一.简介 1.Vector继承关系 2.Vector类扩容 Vector类的实现和ArrayList极其相似,都使用数组存储元素,但是扩容策略不一样,Array ...

  8. cocoa pods自己的笔记

    备注:这里只是个人的观点,有的地方也是copy,多多指教,个人笔记,有侵犯你们版权的地方还望海涵!!! 卡主不动 安装流程:http://www.tuicool.com/articles/qaMfuy ...

  9. guava-retrying 源码解析(停止策略详解)

    一.停止策略相关类 1.停止策略接口:StopStrategy接口,只有一个抽象方法 // 是否应该停止重试.不同的停止策略有不同的实现.boolean shouldStop(Attempt fail ...

  10. linux系统转换root权限

    有时候我们用普通用户的权限没办法完成有关权限,这时候我们就需要拿到root权限才可以,拿到root权限有两种方式 方式一: su - 或者su 此时就会提示你输入密码,输入密码成功以后就能以root权 ...