<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. Bluetooth篇 开发实例之十 官网的Bluetooth Chat sample app.

    运行的时候,会报错: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Action ...

  2. JAVA常见算法题(十四)

    package com.xiaowu.demo; /** * 输入某年某月某日,判断这一天是这一年的第几天? * * * @author WQ * */ public class Demo14 { p ...

  3. win7/win10+vs2015+pcl1.8.0详细配置方案;

    参考网友的资料整理为更详细的解决方案 一.下载相关文件 1.下载PCL-1.8.0-AllInOne-msvc2015-win64.exe.属性表和PDB和测试pcd文件rabbit.pcd,其中,属 ...

  4. 转:Eclipse自动补全功能轻松设置

    Eclipse自动补全功能轻松设置 || 不需要修改编辑任何文件 2012-03-08 21:29:02|  分类: Java |  标签:eclipse  自动补全  设置  |举报|字号 订阅   ...

  5. Ubuntu使用日志2(在Eclipse中搭建C++交叉编译环境)

    Release用交叉编译:arm-none-linux-gnueabi-gcc. 搭建步骤: 1).在Project->Properties->C/C++ Build->Settin ...

  6. java 实体序列化的意义

    一.序列化的意义 客户端访问了某个能开启会话功能的资源, web服务器就会创建一个与该客户端对应的HttpSession对象,每个HttpSession对象都要站用一定的内存空间.如果在某一时间段内访 ...

  7. JavaScript取指定时区的时间

    // 北京是getZoneTime(8),纽约是getZoneTime(-5),班加罗尔是getZoneTime(5.5). 偏移值是本时区相对于格林尼治所在时区的时区差值 function getZ ...

  8. python 第一个web程序

    yum install python-setuptools easy_install pip pip install tornado yum install MySQL-python test.py里 ...

  9. windows快捷键之打开网络连接

      在Win 7"開始"->"执行"对话框输入"cmd"例如以下图红框所看到的,再点击"确定"button. 步骤 ...

  10. MySQL + Amoeba 负载均衡、主从备份方案

    1.  基本环境 4台内网虚拟机的操作系统都是ubuntu-14.04.4 64位 IP为:192.168.169.11.192.168.169.12.192.168.169.13.192.168.1 ...