zoukankan      html  css  js  c++  java
  • 关于Android LinearLayout添加分隔线的方法

    目前了解的办法有两个:1、自定义一个view当作分隔线;2、使用高版本的分隔线属性

    一、在需要添加分隔线的地方,添加一个view,比如ImageView,TextView等都可以,如代码,关键是设置高度要小,宽度要合适

    <ImageView   
            android:layout_width="fill_parent"  
            android:layout_height="1dp"  
            android:background="#00FF00"  
            /> 


    二、就是设置LinearLayout的分隔线属性,参数说明:

      android:showDividers=""    属性有4个值:
      none      不显示分隔线(默认值);
      beginning   在开始处显示分隔线;
      end      在结尾处显示分隔线;
      middle       在每两个组件间显示分隔线:
      除了设置android:showDividers属性外,还要设置android:divider属性,该属性表示分隔线的图像Drawable(该图片的高度就是分隔线的高度,所以要细的

    代码如下:

    android:showDividers="end"  
    android:divider="@drawable/mydivider" 

    也可以不用图片,自己定义一个shape

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
     <size android:width="1dp" />
     <solid android:color="#0000FF00" />
    </shape>

    使用时,直接把这个xml文件当图片一样设置android:divider就好了

  • 相关阅读:
    springmvc
    POJ 3683 Priest John's Busiest Day
    POJ 3678 Katu Puzzle
    HDU 1815 Building roads
    CDOJ UESTC 1220 The Battle of Guandu
    HDU 3715 Go Deeper
    HDU 3622 Bomb Game
    POJ 3207 Ikki's Story IV
    POJ 3648 Wedding
    HDU 1814 Peaceful Commission
  • 原文地址:https://www.cnblogs.com/wytings/p/4141619.html
Copyright © 2011-2022 走看看