razerdp / StrokeLayouts

// 一系列可以自定义描边的layouts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

StrokeLayouts

// 一系列可以自定义描边的layouts(代码极其简单,但很实用)


介绍:

不多说,请看图:

image

Download

依赖(请把{latestVersion}换成上面标签所述版本):

compile 'com.github.razerdp:StrokeLayouts:{latestVersion}'

使用方法:

目前只定义了常用的几个Layout:

  • StrokeRelativeLayout
  • StrokeLinearLayout
  • StrokeFrameLayout

使用与平时的方法没什么不同,自定义控件只增加了边框宽度边框颜色边的排除方法

  <com.razerdp.widgets.StrokeFrameLayout
        ...平常的其他配置
        app:stroke_color="@android:color/holo_green_light"
        app:stroke_width="5dp"
        app:exclude_side="top"// 排除的边,这里配置的边将不会绘制,允许标志位相加
            
            etc : app:exclude_side="top|right|bottom"
            
            //exclude_side取值
            {
                exclude_side:
                    left;
                    top;
                    right;
                    bottom;
                    none;
                    all;
            }
        >

在代码中使用:

 StrokeRelativeLayout rlStroke;
 rlStroke.setExcludeSide(ExcludeSide.EXCLUDE_LEFT);
 
/*
   more : 
   rlStroke.setExcludeSide(ExcludeSide.EXCLUDE_LEFT+ExcludeSide.EXCLUDE_TOP);
   
   or
   rlStroke.setExcludeSide(ExcludeSide.EXCLUDE_LEFT|ExcludeSide.EXCLUDE_TOP);
*/

 
 //ExcludeSide:
ExcludeSide.EXCLUDE_ALL // 排除所有边
ExcludeSide.EXCLUDE_NONE // 不排除边
ExcludeSide.EXCLUDE_LEFT // 排除左边
ExcludeSide.EXCLUDE_TOP // 排除上边
ExcludeSide.EXCLUDE_RIGHT // 排除右边
ExcludeSide.EXCLUDE_BOTTOM // 排除下边
 }

License

MIT

About

// 一系列可以自定义描边的layouts

License:MIT License


Languages

Language:Java 100.0%