android 布局特点
2024-08-28 06:00:54
<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了是不是很简单啊~~快来学习吧~
最新文章
- 【Java每日一题】20161104
- 洛谷⑨月月赛Round2 P3393逃离僵尸岛[最短路]
- class training
- AutoFac使用~IOC容器(DIP,IOC,DI)
- CSS实现图片快速等比例缩放,效果佳
- Nginx下10个安全问题提示
- button swift
- python的urllib2库详细使用说明
- delphi 插入 HTML代码 播放器
- system.badimageformatexception 未能加载文件或程序集
- Java基础知识强化75:正则表达式之分割功能(字符串中的数字排序案例)
- ASP.NET DropDownList FindByValue 未将对象引用设置到对象的实例 解决方法
- HTTP深入浅出 http请求完整过程
- 2018牛客网暑假ACM多校训练赛(第十场)F Rikka with Line Graph 最短路 Floyd
- Django积木块二——邮箱
- 如何利用github打造个人博客专属域名(文字版本)
- VS Code Html Zen coding
- RabbitMQ生产者消费者
- Insert插入不同的列数量,统计信息对比
- OpenVPN多用户配置
热门文章
- http 头信息详解(转)
- Ubifs Support
- 泳池水面fresnel 的近似替代
- C#控件之DataGridView
- MockServer的测试思想与实现
- Java取得操作系统的临时目录
- Linux组件封装(四)使用RAII技术实现MutexLock自动化解锁
- eclispe查看jdk源码后特别卡顿导致未响应解决
- 杂(三)-The type java.lang.Object cannot be resolved It is indirectly referenced ...
- Java种八种常用排序算法