15.Android中LinearLayout布局一些小记录
在App中,我们经常看到布局中会有分割线,直接上代码:
<?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"> <Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="btn1" /> <ImageView
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#e5e5e5"
/> <Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="btn2" /> <LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="#e5e5e5">
</LinearLayout> <Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="btn3" /> <View
android:layout_width="fill_parent"
android:layout_height="0.5dp"
android:background="#e5e5e5"/> </LinearLayout>
运行效果:

实现方法主要放置一个ImageView、View或者LinearLayout组件,然后将其设为分隔线的颜色即可。
同理我们可以通过利用view来设置分开两边部件,代码如下:
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"> <TextView
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_marginLeft="15dp"
android:gravity="center"
android:text="textview1"
android:id="@+id/"textview1""/> <View
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"/> <TextView
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_marginRight="15dp"
android:gravity="center"
android:text="textview2"
android:id="@+id/textview2"/> </LinearLayout>
效果如图:

15.Android中LinearLayout布局一些小记录的更多相关文章
- Android中的布局优化方法
http://blog.csdn.net/rwecho/article/details/8951009 Android开发中的布局很重要吗?那是当然.一切的显示样式都是由这个布局决定的,你说能不重要吗 ...
- 无废话Android之常见adb指令、电话拨号器、点击事件的4种写法、短信发送器、Android 中各种布局(1)
1.Android是什么 手机设备的软件栈,包括一个完整的操作系统.中间件.关键的应用程序,底层是linux内核,安全管理.内存管理.进程管理.电源管理.硬件驱动 2.Dalvik VM 和 JVM ...
- Android笔记(七) Android中的布局——线性布局
我们的软件是由好多个界面组成的,而每个界面又由N多个控件组成,Android中借助布局来让各个空间有条不紊的摆放在界面上. 可以把布局看作是一个可以放置很多控件的容器,它可以按照一定的规律调整控件的位 ...
- Android中得到布局文件对象有三种方式
Android中得到布局文件对象有三种方式 第一种,通过Activity对象 View view = Activity对象.getLayoutInflater().inflater(R.layout. ...
- Android:LinearLayout布局中Layout_weight的深刻理解
首先看一下LinearLayout布局中Layout_weight属性的作用:它是用来分配属于空间的一个属性,你可以设置他的权重.很多人不知道剩余空间是个什么概念,下面我先来说说剩余空间. 看下面代码 ...
- Android中帧布局-FrameLayout和网格布局-GridLayout
帧布局-FrameLayout 一.概念 帧布局中,容器为每个加入其中的空间创建一个空白的区域(成为一帧).每个空间占据一帧,这些帧会按gravity属性自动对齐. 帧布局的效果是将其中的所有空间叠加 ...
- 什么是布局?Android中的布局是怎样的?
布局管理器(通常被称为是布局)是对ViewGroup类的扩展,是用来控制子控件在UI中的位置. Android SDK包含了许多布局类,在为视图.Fragment和Activity创建UI时,可以使用 ...
- 在android中配置 slf4j + log4j 日志记录框架
需求: 在项目开发中,需要记录 操作日志 .起初自己写了个简单的日志记录文本写入到文本的方法,后来随着项目的膨胀,需要考虑更多的操作,开始考虑性能问题. 实现: 考虑使用 slf4j + log4j ...
- Android中常用布局单位
Android在UI布局时经常用到一些单位,对单位混用直接会影响UI的显示,要想正确的在布局中使用每种单位就必须先真正的熟悉它. UI显示效果的影响因素:屏幕尺寸.屏幕密度.分辨率:而android手 ...
随机推荐
- Ajax读取文件时出现的缓存问题
对于Ajax缓存问题时,由于浏览器的版本问题,有时候当服务器端已更改文件中的内容,而客户端并得不到更新后的文件,而是延续之前的文件内容,解决办法是:在读取的文件内容后加一串的地址:JSON的格式为[{ ...
- Unity3D开发赛车Demo遇到的问题
遇到问题 在3D Max中导出的跑车在Unity中轴向不对,不知有没有朋友遇到过呢? 切换坐标系统 在Unity3D中按X键,切换坐标系统 车轮方向变了 运行游戏之后,赛车的车轮方向变歪了 车依然能跑 ...
- 转: 借助GitHub托管你的项目代码
转自:http://www.cnblogs.com/edisonchou/p/5990875.html 备注: 原贴关于github使用说明,非常详细易懂.建议看原帖. 借助GitHub托管你的项目代 ...
- TP第一天路由解析
路由解析:支持四种URL模式,分别是普通模式.路径模式.重写模式.兼容模式,分别用0123表示 普通模式:http://网址/index.php?m=model&c=user&a=lo ...
- 阻塞与非阻塞IO step by step
谈到IO,阻塞.非阻塞,异步.同步是绕不开的话题.说实话,我也没搞清楚,网上查了许多资料,大家众说纷纭,一种比较靠谱的说法是:”在处理 IO 的时候,阻塞和非阻塞都是同步 IO,使用使用了特殊的API ...
- CAN开发中遇到的奇怪问题
问题背景: 之前在做USBCAN2开发过程中,遇到一个奇葩问题,当我们加上其中某一句代码时,我们的程序会走不下去,得不到数据,而且在调试的过程中,你也不能暂停,不然,你也得不到数据.后来参考网上一篇帖 ...
- python大数据工作流程
本文作者:hhh5460 大数据分析,内存不够用怎么办? 当然,你可以升级你的电脑为超级电脑. 另外,你也可以采用硬盘操作. 本文示范了硬盘操作的一种可能的方式. 本文基于:win10(64) + p ...
- Asp.net设计模式笔记之二:应用程序分离与关注点分离
本次笔记主要涉及的内容如下: 1.将智能UI(SmartUI)反模式重构成分层方式的示例代码 2.分层设计与传统的Asp.net WebForm模型(代码后植)相比具有的优势 3.逻辑分层概念以及分离 ...
- 用python简单处理图片(3):添加水印
python版本:3.4 Pillow版本:3.0 一.添加文字水印 from PIL import Image, ImageDraw,ImageFont im = Image.open(" ...
- gdb调试汇编堆栈分析
代码(src/05/gdb.c) int g(int x) { return x + 4; } int f(int x) { return g(x); } int main(void) { retur ...