All Projects → DrownCoder → SupperShape

DrownCoder / SupperShape

Licence: other
🏡替代Shape和Selector和Layer-list的xml,减小apk体积

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to SupperShape

Backgroundlibrary
A framework for directly generating shape through Tags, no need to write shape.xml again(通过标签直接生成shape,无需再写shape.xml)
Stars: ✭ 3,179 (+5477.19%)
Mutual labels:  shape, selector
RadiusView
[1.1.0以后版本由UIWidget维护,不做更新]Android 实现一个用于需要圆角矩形框背景的TextView或Layout的情况,减少直接使用时引入的shape资源文件,包括RadiusTextView,RadiusEditText,RadiusLinearLayout,RadiusRelativeLayout,RadiusFrameLayout,RadiusCheckBox,RadiusRadioButton,主要有圆角控制、默认背景(边框线)、按下背景(边框线)、不可点击背景(边框线)、选择selected背景(边框线)、选中checked背景(边框线);全圆角、四角单独设置圆角功能
Stars: ✭ 13 (-77.19%)
Mutual labels:  shape, radius
Rwidgethelper
Android UI 快速开发,专治原生控件各种不服
Stars: ✭ 996 (+1647.37%)
Mutual labels:  shape, selector
Gooey React
The gooey effect for React, used for shape blobbing / metaballs (0.5 KB) 🧽
Stars: ✭ 219 (+284.21%)
Mutual labels:  shape
Music Cover View
Subclass of ImageView that 'morphs' into a circle shape and can rotates. Useful to be used as album cover in Music apps. 📀🎶
Stars: ✭ 239 (+319.3%)
Mutual labels:  shape
combining3Dmorphablemodels
Project Page of Combining 3D Morphable Models: A Large scale Face-and-Head Model - [CVPR 2019]
Stars: ✭ 80 (+40.35%)
Mutual labels:  shape
react-dom-inject
Binds an HTML element by selector to a ReactElement and renders to a DOM tree (with redux injection)
Stars: ✭ 18 (-68.42%)
Mutual labels:  selector
D3 3d
D3.js plugin for 3d visualization
Stars: ✭ 203 (+256.14%)
Mutual labels:  shape
dialup-admin
The WebGUI administration tool for the FreeRADIUS server
Stars: ✭ 30 (-47.37%)
Mutual labels:  radius
radiusd
Distributed Radius-server to do authentication+accounting.
Stars: ✭ 50 (-12.28%)
Mutual labels:  radius
ACRay
AnyConnect With V2Ray
Stars: ✭ 29 (-49.12%)
Mutual labels:  radius
ShapeView
打造万能shape,再也不用写很多xml了,可以当做TextView,Button,EditText等多种控件,方便实用
Stars: ✭ 34 (-40.35%)
Mutual labels:  shape
Shape-Your-Music
A web application for drawing music.
Stars: ✭ 106 (+85.96%)
Mutual labels:  shape
Motion Shapeofview
Explain how to use MotionLayout with ShapeOfView
Stars: ✭ 236 (+314.04%)
Mutual labels:  shape
SwiftUI-bez
Utilities for working with bezier curves in SwiftUI
Stars: ✭ 80 (+40.35%)
Mutual labels:  shape
Flutter Shapeofview
Give a custom shape to any flutter widget, Material Design 2 ready
Stars: ✭ 211 (+270.18%)
Mutual labels:  shape
SquareImageView
SquareImageView is a simple wrapper library for Android ImageView
Stars: ✭ 28 (-50.88%)
Mutual labels:  shape
react-native-bottom-bar
Fully customizable BottomBar with unique design shape for React Native.
Stars: ✭ 74 (+29.82%)
Mutual labels:  shape
EasyTextView
🌈 🍀支持Java和Xml设置Shape、IconFont、IconFont+String、Span等具有丰富Api的TextView
Stars: ✭ 71 (+24.56%)
Mutual labels:  shape
radius-rs
An async/await native implementation of the RADIUS server and client for Rust.
Stars: ✭ 56 (-1.75%)
Mutual labels:  radius

通过封装GradientDrawable、StateListDrawable 、LayerDrawable 代替每次都需要创建一个shape.xml的不便,一定程度上也可以减少apk体积,并且使用简单。

Wercker Hex.pm

基于此项目拓展的多功能EastTextView已开源,欢迎使用

一个基于iconfont拓展的支持多种功能的轻量级TextView,减少布局嵌套,减少定义shape文件,基本涵盖常规需要多个TextView实现的功能。

功能

  • 不用再写shape.xml文件了!!!
  • 链式调用
  • 涵盖Shape几乎常用的所有属性,如:TYPE,Radius,Stroke,Solid,Gradient,GradientType,GradientCenter,GradientRadius,size
  • 支持Selector
  • 支持Layer-list

How to:

Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories:

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Step 2. Add the dependency

dependencies {
	        compile 'com.github.sdfdzx:SupperShape:v1.0.4'
	}

效果

使用

一、ShapeBuilder代替shape。

Demo

ShapeBuilder.create()
            .Type(RECTANGLE)
            .Solid(Color.RED)
            .Stroke(5,Color.BLACK)
            .build(View);

Use

设置对应的属性,调用build(View)传入需要设置背景的view即可。获得构建的drawable可以调用该build()方法返回。

Api

1.type形状属性 type:RECTANGLE,OVAL,LINE,RING

Type(int type)

2.Stroke边框属性

    /**
     * 边线
     * @param px -width,需要px值
     * @param color -color值
     * @param dashWidth -dashWidth 横线的宽度
     * @param dashGap -dashGap 点与点间的距离
     */
public ShapeBuilder Stroke(int px, int color) 
public ShapeBuilder Stroke(int px, int color, int dashWidth, int dashGap)

3.Solid填充属性

    /**
     *
     * @param color -背景颜色
     */
    public ShapeBuilder Solid(int color)

4.Radius圆角属性

    /**
     *
     * @param px -圆角,四个角保持一致
     */
    public ShapeBuilder Radius(float px)
    /*
     * 圆角
     * @param topleft 左上
     * @param topright 右上
     * @param botleft 左下
     * @param botright 右下
     */
    public ShapeBuilder Radius(float topleft, float topright, float botleft, float botright)

5.Gradient渐变属性

    /*
     * 渐变,默认的Linear渐变
     * @param startColor 开始颜色
     * @param centerColor 中心颜色
     * @param endColor 结束颜色
     */
    public ShapeBuilder Gradient(int startColor, int centerColor, int endColor)
	// @param angle 角度,需要是45的整数倍
	public ShapeBuilder Gradient(int angle, int startColor, int centerColor, int endColor)
    /*
     * 渐变,设置渐变方向
     * @param orientation 方向支持类型
     *                    0-LEFT_RIGHT
     *                    45-BL_TR
     *                    90-BOTTOM_TOP
     *                    135-BR_TL
     *                    180-RIGHT_LEFT
     *                    225-TR_BL
     *                    270-TOP_BOTTOM
     *                    315-TL_BR
     */
    public ShapeBuilder Gradient(GradientDrawable.Orientation orientation, int startColor, int
            centerColor, int endColor)

6.GradientType渐变类型属性

    /*
     * 渐变type
     * @param type linear (default.)-LINEAR_GRADIENT
     *             circular-RADIAL_GRADIENT
     *             sweep-SWEEP_GRADIENT
     * @return
     */
    public ShapeBuilder GradientType(int type)

7.GradientCenter渐变中心属性

    /*
     *  这两个属性只有在type不为linear情况下起作用。
     * @param x 相对X的渐变位置
     * @param y 相对Y的渐变位置
     * @return
     */
    public ShapeBuilder GradientCenter(float x, float y)

8.GradientRadius渐变颜色半径

    /*
     * 该属性只有在type="radial"有效
     * @param radius 渐变颜色的半径
     * @return
     */
    public ShapeBuilder GradientRadius(float radius)

9.Size属性

    /*
     * 设置size
     * @param width 宽
     * @param height 高
     * @return
     */
    public ShapeBuilder setSize(int width, int height)

二、ShapeListBuilder替代Selector

Demo

        ShapeBuilder builder1 = ShapeBuilder.create()
                .Type(RECTANGLE)
                .Solid(Color.RED);
        ShapeBuilder builder2 = ShapeBuilder.create()
                .Type(RECTANGLE)
                .Solid(Color.RED);

        ShapeListBuilder.create(builder1.build())
                .addShape(builder2.Solid(Color.BLUE).build(), android.R.attr.state_selected)
                .build(findViewById(R.id.tv1));

        findViewById(R.id.tv1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                findViewById(R.id.tv1).setSelected(!findViewById(R.id.tv1).isSelected());
            }
        });

Use

1.传入默认状态的drawable

    /*
     * @param drawable 传入默认状态下的drawable
     */
    public static ShapeListBuilder create(Drawable drawable)

2.添加对应状态的drawable

    /*
     * 添加状态
     * @param shape 状态对应的shape
     * @param state 状态类型
     */
    public ShapeListBuilder addShape(Drawable shape, int... state)

(这里要注意添加的顺序,只要有一个状态与之相配,背景就会被换掉。所以不要把大范围放在前面了,会造成没有什么效果了。)
3.build(View)即可

三、LayerBuilder替代Layer-list

Demo

LayerBuilder.create(builder1.build(), builder2.build()).Bottom(1, 15).build(findViewById(R
                .id.tv3));

Use

1.传入多个drawable

public static LayerBuilder create(Drawable... drawables)

2.设置index的偏移量

public LayerBuilder Left(int index, int px)
public LayerBuilder Top(int index, int px)
public LayerBuilder Right(int index, int px)
public LayerBuilder Bottom(int index, int px)
public LayerBuilder setInset(int index,int left,int top,int right,int bottom)

3.build(View)即可

License

Copyright 2017 [DrownCoder] 

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].