<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 布局特点的更多相关文章

  1. 【转】在Android布局中使用include和merge标签

    内容转自:http://fengweipeng1208.blog.163.com/blog/static/21277318020138229754135/ 在我们开发android布局时,经常会有很多 ...

  2. Android成长日记-Android布局优化

    Android常用布局 1. LinearLayout(线性布局) 2. RelativeLayout(相对布局) 3. TableLayout(表格布局) 4. AbsoluteLayou(绝对布局 ...

  3. 【转】Android布局优化之ViewStub

    ViewStub是Android布局优化中一个很不错的标签/控件,直接继承自View.虽然Android开发人员基本上都听说过,但是真正用的可能不多. ViewStub可以理解成一个非常轻量级的Vie ...

  4. Android 布局之LinearLayout

    Android 布局之LinearLayout 1 LinearLayout简介 LinearLayout是线程布局.它包括2个方向(android:orientation):“水平”(horizon ...

  5. Android 布局之RelativeLayout

    Android 布局之RelativeLayout 1 RelativeLayout简介 RelativeLayout是相对布局. RelativeLayout布局属性 1.1 与parent相对的属 ...

  6. Android 布局之TableLayout

    Android 布局之TableLayout 1 TableLayout简介 TableLayout是表格布局.TableLayout 可设置的属性包括全局属性及单元格属性. 1.1 全局属性 有以下 ...

  7. Android 布局之FrameLayout

    Android 布局之FrameLayout 1 FrameLayout简介 对于FrameLayout,官方介绍是:FrameLayout is designed to block out an a ...

  8. Android 布局之GridLayout

    Android 布局之GridLayout 1 GridLayout简介 GridLayout是Android4.0新提供的网格矩阵形式的布局控件. GridLayout的继承关系如下:java.la ...

  9. Xamarin Android布局文件没有智能提示

    Xamarin Android布局文件没有智能提示 在Visual Studio 2015中,Android项目的Main.axml文件没有智能提示,不便于布局文件的编写.解决办法:(1)从Xamar ...

  10. Android布局---相对布局

    Android布局分为五大类:相对布局.线性布局.表格布局.帧布局.网格布局 相对布局 语法格式: <RelativeLayout xmlns:android="http://sche ...

随机推荐

  1. MyBatis参数为Integer型并赋值为0时判断失误的问题解决

    mybatis.xml中有if判断条件判断参数不为空时,赋值为0的Integer参数被MyBatis判断为空,因此不执行<if test="param != null and para ...

  2. NHibernate官方文档——第八章 继承映射(Inheritance Mapping)

    本文翻译自NHibernate官方文档NHibernate Reference Documentation 4.1. 受限于个人知识水平,有些地方翻译可能不准确,但是我还是希望我的这些微薄的努力能为他 ...

  3. UBIFS - UBI File-System

    参考:http://www.linux-mtd.infradead.org/doc/ubifs.html#L_raw_vs_ftl UBIFS - UBI File-System Table of c ...

  4. MTD

    内存技术设备(英语:Memory Technology Device,缩写为 MTD),是Linux系统中设备文件系统的一个类别,主要用于快闪存储器的应用,是一种快闪存储器转换层(Flash Tran ...

  5. 数据库读写锁的实现(C++)

    一.基本概念 在数据库中,对某数据的两个基本操作为写和读.分布有两种锁控制:排它锁(X锁).共享锁(S锁). 排它锁(x锁):若事务T对数据D加X锁,则其他不论什么事务都不能再对D加不论什么类型的锁. ...

  6. C#中 protected internal 和 internal 的区别

    http://kudick.blog.163.com/blog/static/1666066320091055414453/ DoDo: protected: 爷爷有一张银行卡,爸爸可以用,儿子也可以 ...

  7. 高效重构 C++ 代码

    引言 Martin Fowler的<重构:改善既有代码的设计>一书从2003年问世至今已有十几年时间了,按照计算机领域日新月异的变化速度,重构已经算是一门陈旧的技术了.但是陈旧并不代表不重 ...

  8. java中XML操作:xml与string互转、读取XML文档节点及对XML节点增删改查

    一.XML和String互转: 使用dom4j程式变得很简单 //字符串转XML String xmlStr = \"......\"; Document document = D ...

  9. 新人补钙系列教程之:AS3 与 PHP 简单通信基础

    package { import flash.display.Loader; import flash.events.Event; import flash.net.URLLoader; import ...

  10. 用键盘控制DIV && Div闪烁

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...