Code Monkey home page Code Monkey logo

ulfy-shape-layout's Introduction

img

引入依赖

Download

implementation 'com.ulfy.android.controls:shape-layout:x.x.x'

圆形

圆形不带边框

<com.ulfy.android.controls.ShapeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_shape="circle">
    
    ...
    
</com.ulfy.android.controls.ShapeLayout>

圆形带边框

<com.ulfy.android.controls.ShapeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="5dp"
    app:layout_shape="circle"
    app:shape_background="@drawable/meinv">
    
    ...
    
</com.ulfy.android.controls.ShapeLayout>

矩形不带边框

<com.ulfy.android.controls.ShapeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_shape="rect"
    app:rect_radius="10dp"
    app:rect_radius_left_top="30dp"
    app:rect_radius_right_top="30dp">
    
    ...
    
</com.ulfy.android.controls.ShapeLayout>

矩形带边框

<com.ulfy.android.controls.ShapeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:padding="5dp"
    app:layout_shape="rect"
    app:rect_radius="10dp"
    app:rect_radius_left_top="30dp"
    app:rect_radius_right_top="30dp"
    app:shape_background="#F00">
    
    ...
    
</com.ulfy.android.controls.ShapeLayout>
    

代码设置

// 查找布局
ShapeLayout shapeSL = findViewById(R.id.shapeSL);

// 设置圆形
shapeSL.setShapeCircle();

// 设置矩形
shapeSL.setShapeRect(10);               // px
shapeSL.setShapeRect(10, 10, 10, 10);   // px

// 设置背景,如果显示边框需要设置padding
shapeSL.setShapeBackgroundColor(Color.BLUE);
shapeSL.setShapeBackgroundResource(R.drawable.meinv);
shapeSL.setShapeBackground(new ColorDrawable(Color.BLUE));

ulfy-shape-layout's People

Contributors

ulfyyang avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.