1. <LinearLayout
  2. android:layout_width="wrap_content"
  3. android:layout_height="wrap_content"
  4. android:orientation="horizontal">
  5. <TextView
  6. android:id="@+id/item_title"
  7. android:layout_width="wrap_content"
  8. android:layout_height="match_parent"
  9. android:layout_marginLeft="10dp"
  10. android:layout_toLeftOf="@+id/iv_more"
  11. android:layout_toRightOf="@id/item_image"
  12. android:ellipsize="end"
  13. android:lines="1"
  14. android:singleLine="true"
  15. android:text="欢迎观看我的博客"
  16. android:textColor="@color/fontColor"
  17. android:textSize="14sp" />
  18. <TextView
  19. android:id="@+id/item_look"
  20. android:layout_width="wrap_content"
  21. android:layout_height="match_parent"
  22. android:layout_marginLeft="10dp"
  23. android:layout_toLeftOf="@+id/iv_more"
  24. android:layout_toRightOf="@id/item_image"
  25. android:ellipsize="end"
  26. android:lines="1"
  27. android:singleLine="true"
  28. android:text="试看"
  29. android:textColor="@color/mainColor"
  30. android:textSize="11sp"
  31. android:background="@drawable/shape_column_look"/>
  32. </LinearLayout>

上面的布局就是上图框中的布局 ,这里我们想实现的是这样

但往往出现了这样

我们希望的是试看不会被顶掉,但虽然看着简单其实,如果不知道使用布局技巧的话就只能自定义view了,但自定义View的计算还是非常麻烦

解决方案:

其实布局很简单就只要加一句

  1. android:layout_weight="1"
  1. 如下
  1. <LinearLayout
  2. android:layout_width="wrap_content"
  3. android:layout_height="wrap_content"
  4. android:orientation="horizontal">
  5. <TextView
  6. android:id="@+id/item_title"
  7. android:layout_width="wrap_content"
    android:layout_weight="1"
  8. android:layout_height="match_parent"
  9. android:layout_marginLeft="10dp"
  10. android:layout_toLeftOf="@+id/iv_more"
  11. android:layout_toRightOf="@id/item_image"
  12. android:ellipsize="end"
  13. android:lines="1"
  14. android:singleLine="true"
  15. android:text="欢迎观看我的博客"
  16. android:textColor="@color/fontColor"
  17. android:textSize="14sp" />
  18. <TextView
  19. android:id="@+id/item_look"
  20. android:layout_width="wrap_content"
  21. android:layout_height="match_parent"
  22. android:layout_marginLeft="10dp"
  23. android:layout_toLeftOf="@+id/iv_more"
  24. android:layout_toRightOf="@id/item_image"
  25. android:ellipsize="end"
  26. android:lines="1"
  27. android:singleLine="true"
  28. android:text="试看"
  29. android:textColor="@color/mainColor"
  30. android:textSize="11sp"
  31. android:background="@drawable/shape_column_look"/>
  32. </LinearLayout>
  1. ok了是不是很简单啊~~快来学习吧~
  2.  

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. IIS Express HTTP 错误 500.22

    错误描述: HTTP 错误 500.22 - Internal Server Error 检测到在集成的托管管道模式下不适用的 ASP.NET 设置. 最可能的原因: 此应用程序在 system.we ...

  2. GTK+重拾--09 GTK+中的组件(一)

    (一):写在前面 在这篇文章中主要介绍了GTK+程序中的各种构件,这是解说构件的第一个部分,另外一部分将在下一个小节中讲到. 构件是建立一个GUI程序的基础.在GTK+的长期发展过程中.一些特定的构件 ...

  3. apache 限制某些目录不能访问通过rewrite实现

    通过deny allow访问控制肯定是可以实现的单个目录,但是这个必须指定准确的目录,如果有很多个目录,但是都包含某个名字,比如bbs.1.com/1/tmp/123.htmlbbs.1.com/2/ ...

  4. 机器学习第2课:单变量线性回归(Linear Regression with One Variable)

    2.1  模型表示 之前的房屋交易问题为例,假使我们回归问题的训练集(Training Set)如下表所示: 我们将要用来描述这个回归问题的标记如下: m                代表训练集中实 ...

  5. 使用Ant构建简单项目

    Apache Ant主要用于Java项目的构建.为什么要使用Ant: 1)项目构建不是简单的编译,各种资源需要合理构建,例如有的类需要压缩成jar文件,有的文件需要放在指定位置,有时候需要使用配置文件 ...

  6. [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 ...

  7. JAVA反射机制--怎么不受泛型束缚给数组赋值

    在Java中,声明数组的时候我们经常会写泛型限制用户输入或者获取的数据.如:ArrayList<String> list = new ArrayList<>(); String ...

  8. Linux中MySQL数据库max_allowed_packet的调整

    在MySQL数据库里某表有一个blob字段,当上传文件超过1M的时候出现下面的错误: PreparedStatementCallback; SQL [insert into uos.docfile(r ...

  9. @classmethod, @staticmethod和@property这三个装饰器的使用对象是在类中定义的函数。下面的例子展示了它们的用法和行为:

    class MyClass(object): def __init__(self): self._some_property = "properties are nice" sel ...

  10. 微信公众号 - js传入时间戳换算(以前几天、几小时...)

    // 获取当前时间戳 function timestamps() { return Math.round(new Date().getTime() / 1000).toString() } // 距离 ...