GithubHelp home page GithubHelp logo

qinghua0706 / shadowlayout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lijiankun24/shadowlayout

0.0 1.0 0.0 1.88 MB

简单好用的阴影库-ShadowLayout

Home Page: http://lijiankun24.com/简单好用的阴影库-ShadowLayout/

Java 100.00%

shadowlayout's Introduction

ShadowLayout

Download

Read this in other languages: 中文English 

Intro

The result of using ShadowLayout is as follows:

By using ShadowLayout, you can set the color、shape、radius、display boundary (all|left|right|top|bottom), the offset of the x-axis and the y-axis of shadow.

You can change the color and radius of shadow dynamically, as follows:

How to use ShadowLayout

Setting up the dependency

Gradle:

    implementation 'com.lijiankun24:shadowlayout:x.y.z'

Maven:

    <dependency>
      <groupId>com.lijiankun24</groupId>
      <artifactId>shadowlayout</artifactId>
      <version>x.y.z</version>
      <type>pom</type>
    </dependency>

Please replace x and y and z with the latest version numbers:Download

Show Shadow

config in xml:

    <com.lijiankun24.shadowlayout.ShadowLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="30dp"
        app:shadowColor="#66000000"
        app:shadowShape="rectangle"
        app:shadowDx="0dp"
        app:shadowDy="3dp"
        app:shadowRadius="10dp"
        app:shadowSide="all">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@android:color/white"
            android:contentDescription="@null"
            android:src="@mipmap/ic_launcher"/>
    </com.lijiankun24.shadowlayout.ShadowLayout>

The result of above xml is as follows:

There are 6 properties in xml:

  • app:shadowColor="#66000000" set the color of shadow,notice:Color must have a alpha value
  • app:shadowShape="rectangle|oval" set the shape of shadow:rectangle|oval
  • app:shadowDx="0dp" set the shadow x-axis offset
  • app:shadowDy="3dp" set the shadow y-axis offset
  • app:shadowRadius="10dp" set the radius of shadow
  • app:shadowSide="all|left|right|top|bottom" set the display boundary (all|left|right|top|bottom) of shadow

Change shadow dynamically

// change the color of shadow
ShadowLayout slOval = findViewById(R.id.sl_oval);
slOval.setShadowColor(ContextCompat.getColor(this, R.color.drak_yellow))

// change the color of shadow
ShadowLayout slRectangle = findViewById(R.id.sl_rectangle)
slRectangle.setShadowColor(Color.parseColor("#EE00FF7F"));

// change the radius of shadow
ShadowLayout slRadius = findViewById(R.id.sl_radius);
slRadius.setShadowRadius(dip2px(12))

the result is as follows:

Welcome to star and fork, and welcome to download the ShadowLayoutExample.apk to experience. if any questions are welcome. My work email: [email protected]

License

Copyright 2018 lijiankun24

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.

shadowlayout's People

Contributors

lijiankun24 avatar

Watchers

James Cloos 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.