android 布局特点
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal">
- <TextView
- android:id="@+id/item_title"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_marginLeft="10dp"
- android:layout_toLeftOf="@+id/iv_more"
- android:layout_toRightOf="@id/item_image"
- android:ellipsize="end"
- android:lines="1"
- android:singleLine="true"
- android:text="欢迎观看我的博客"
- android:textColor="@color/fontColor"
- android:textSize="14sp" />
- <TextView
- android:id="@+id/item_look"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_marginLeft="10dp"
- android:layout_toLeftOf="@+id/iv_more"
- android:layout_toRightOf="@id/item_image"
- android:ellipsize="end"
- android:lines="1"
- android:singleLine="true"
- android:text="试看"
- android:textColor="@color/mainColor"
- android:textSize="11sp"
- android:background="@drawable/shape_column_look"/>
- </LinearLayout>
上面的布局就是上图框中的布局 ,这里我们想实现的是这样
但往往出现了这样
我们希望的是试看不会被顶掉,但虽然看着简单其实,如果不知道使用布局技巧的话就只能自定义view了,但自定义View的计算还是非常麻烦
解决方案:
其实布局很简单就只要加一句
- android:layout_weight="1"
- 如下
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal">
- <TextView
- android:id="@+id/item_title"
- android:layout_width="wrap_content"
android:layout_weight="1"- android:layout_height="match_parent"
- android:layout_marginLeft="10dp"
- android:layout_toLeftOf="@+id/iv_more"
- android:layout_toRightOf="@id/item_image"
- android:ellipsize="end"
- android:lines="1"
- android:singleLine="true"
- android:text="欢迎观看我的博客"
- android:textColor="@color/fontColor"
- android:textSize="14sp" />
- <TextView
- android:id="@+id/item_look"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_marginLeft="10dp"
- android:layout_toLeftOf="@+id/iv_more"
- android:layout_toRightOf="@id/item_image"
- android:ellipsize="end"
- android:lines="1"
- android:singleLine="true"
- android:text="试看"
- android:textColor="@color/mainColor"
- android:textSize="11sp"
- android:background="@drawable/shape_column_look"/>
- </LinearLayout>
- 就ok了是不是很简单啊~~快来学习吧~
android 布局特点的更多相关文章
- 【转】在Android布局中使用include和merge标签
内容转自:http://fengweipeng1208.blog.163.com/blog/static/21277318020138229754135/ 在我们开发android布局时,经常会有很多 ...
- Android成长日记-Android布局优化
Android常用布局 1. LinearLayout(线性布局) 2. RelativeLayout(相对布局) 3. TableLayout(表格布局) 4. AbsoluteLayou(绝对布局 ...
- 【转】Android布局优化之ViewStub
ViewStub是Android布局优化中一个很不错的标签/控件,直接继承自View.虽然Android开发人员基本上都听说过,但是真正用的可能不多. ViewStub可以理解成一个非常轻量级的Vie ...
- Android 布局之LinearLayout
Android 布局之LinearLayout 1 LinearLayout简介 LinearLayout是线程布局.它包括2个方向(android:orientation):“水平”(horizon ...
- Android 布局之RelativeLayout
Android 布局之RelativeLayout 1 RelativeLayout简介 RelativeLayout是相对布局. RelativeLayout布局属性 1.1 与parent相对的属 ...
- Android 布局之TableLayout
Android 布局之TableLayout 1 TableLayout简介 TableLayout是表格布局.TableLayout 可设置的属性包括全局属性及单元格属性. 1.1 全局属性 有以下 ...
- Android 布局之FrameLayout
Android 布局之FrameLayout 1 FrameLayout简介 对于FrameLayout,官方介绍是:FrameLayout is designed to block out an a ...
- Android 布局之GridLayout
Android 布局之GridLayout 1 GridLayout简介 GridLayout是Android4.0新提供的网格矩阵形式的布局控件. GridLayout的继承关系如下:java.la ...
- Xamarin Android布局文件没有智能提示
Xamarin Android布局文件没有智能提示 在Visual Studio 2015中,Android项目的Main.axml文件没有智能提示,不便于布局文件的编写.解决办法:(1)从Xamar ...
- Android布局---相对布局
Android布局分为五大类:相对布局.线性布局.表格布局.帧布局.网格布局 相对布局 语法格式: <RelativeLayout xmlns:android="http://sche ...
随机推荐
- IIS Express HTTP 错误 500.22
错误描述: HTTP 错误 500.22 - Internal Server Error 检测到在集成的托管管道模式下不适用的 ASP.NET 设置. 最可能的原因: 此应用程序在 system.we ...
- GTK+重拾--09 GTK+中的组件(一)
(一):写在前面 在这篇文章中主要介绍了GTK+程序中的各种构件,这是解说构件的第一个部分,另外一部分将在下一个小节中讲到. 构件是建立一个GUI程序的基础.在GTK+的长期发展过程中.一些特定的构件 ...
- apache 限制某些目录不能访问通过rewrite实现
通过deny allow访问控制肯定是可以实现的单个目录,但是这个必须指定准确的目录,如果有很多个目录,但是都包含某个名字,比如bbs.1.com/1/tmp/123.htmlbbs.1.com/2/ ...
- 机器学习第2课:单变量线性回归(Linear Regression with One Variable)
2.1 模型表示 之前的房屋交易问题为例,假使我们回归问题的训练集(Training Set)如下表所示: 我们将要用来描述这个回归问题的标记如下: m 代表训练集中实 ...
- 使用Ant构建简单项目
Apache Ant主要用于Java项目的构建.为什么要使用Ant: 1)项目构建不是简单的编译,各种资源需要合理构建,例如有的类需要压缩成jar文件,有的文件需要放在指定位置,有时候需要使用配置文件 ...
- [Unit Testing] Mock a Node module's dependencies using Proxyquire
Sometimes when writing a unit test, you know that the module you're testing imports a module that yo ...
- JAVA反射机制--怎么不受泛型束缚给数组赋值
在Java中,声明数组的时候我们经常会写泛型限制用户输入或者获取的数据.如:ArrayList<String> list = new ArrayList<>(); String ...
- Linux中MySQL数据库max_allowed_packet的调整
在MySQL数据库里某表有一个blob字段,当上传文件超过1M的时候出现下面的错误: PreparedStatementCallback; SQL [insert into uos.docfile(r ...
- @classmethod, @staticmethod和@property这三个装饰器的使用对象是在类中定义的函数。下面的例子展示了它们的用法和行为:
class MyClass(object): def __init__(self): self._some_property = "properties are nice" sel ...
- 微信公众号 - js传入时间戳换算(以前几天、几小时...)
// 获取当前时间戳 function timestamps() { return Math.round(new Date().getTime() / 1000).toString() } // 距离 ...