zoukankan      html  css  js  c++  java
  • android 布局特点

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




  • 相关阅读:
    HTTP状态码详解
    phpcms v9调用多个栏目下文章的方法
    纯CSS3制作学生入学档案表单样式代码
    phpcmsv9 标题颜色显示问题
    Excel中利用IF和TIME函数计算出上下班状态!
    excel if判断时间段早晚班
    PHPCMS列表页伪静态
    EXCEL IF 函数 模糊查询
    如何用js实现截取一个字符串中的数字
    Elasticsearch学习之基本核心概念
  • 原文地址:https://www.cnblogs.com/woaixingxing/p/6834736.html
Copyright © 2011-2022 走看看