<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了是不是很简单啊~~快来学习吧~

最新文章

  1. 【Java每日一题】20161104
  2. 洛谷⑨月月赛Round2 P3393逃离僵尸岛[最短路]
  3. class training
  4. AutoFac使用~IOC容器(DIP,IOC,DI)
  5. CSS实现图片快速等比例缩放,效果佳
  6. Nginx下10个安全问题提示
  7. button swift
  8. python的urllib2库详细使用说明
  9. delphi 插入 HTML代码 播放器
  10. system.badimageformatexception 未能加载文件或程序集
  11. Java基础知识强化75:正则表达式之分割功能(字符串中的数字排序案例)
  12. ASP.NET DropDownList FindByValue 未将对象引用设置到对象的实例 解决方法
  13. HTTP深入浅出 http请求完整过程
  14. 2018牛客网暑假ACM多校训练赛(第十场)F Rikka with Line Graph 最短路 Floyd
  15. Django积木块二——邮箱
  16. 如何利用github打造个人博客专属域名(文字版本)
  17. VS Code Html Zen coding
  18. RabbitMQ生产者消费者
  19. Insert插入不同的列数量,统计信息对比
  20. OpenVPN多用户配置

热门文章

  1. http 头信息详解(转)
  2. Ubifs Support
  3. 泳池水面fresnel 的近似替代
  4. C#控件之DataGridView
  5. MockServer的测试思想与实现
  6. Java取得操作系统的临时目录
  7. Linux组件封装(四)使用RAII技术实现MutexLock自动化解锁
  8. eclispe查看jdk源码后特别卡顿导致未响应解决
  9. 杂(三)-The type java.lang.Object cannot be resolved It is indirectly referenced ...
  10. Java种八种常用排序算法