Giter VIP home page Giter VIP logo

blurrylayout's Introduction

BlurryLayout

Create a beautiful blurry background with simple code and less work.

Use this layout to place views above it while keeping the background awesome. Use your image and colors to come up with a cool layout that matches your needs

Screenshot

Setup

First include the library in your project with:

dependencies {
    implementation 'com.revosleap.layout:blurrylayout:1.0.1'
}

In your layout.xml file, set the parent layout as:

<com.revosleap.blurrylayout.BlurryLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/blurLayout"
    tools:context=".Blurry">
</com.revosleap.blurrylayout.BlurryLayout>

Xml Attributes

You can set xml atttributes to you layout as follows:

create namespace declaration xmlns:app="http://schemas.android.com/apk/res-auto" then add attributes as:

    app:blurColor="@android:color/white" <!--takes Color value int-->
    app:blurOpacity=".4" <!--takes value float-->
    app:blurImage="@drawable/together" <!--takes image drawable-->
    app:blurRadius="13" <!--takes value int-->

Sample

<com.revosleap.blurrylayout.BlurryLayout

    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/blurLayout"
    tools:context=".Blurry"
    app:blurColor="@android:color/white"
    app:blurOpacity=".4"
    app:blurImage="@drawable/together"
    app:blurRadius="13"
    >

Programatically

In your activity class you need to pass the image to be used as background;

Create an instance of the class like:

BlurryLayout blurLayout = findViewById(R.id.blurLayout);

Image blur

Set image and blur radius as

blurLayout.blurBackground(bitmap,10);

Note: blur radius takes int. It determines the amount of the blur effect.

Blur color

Set as:

blurLayout.blurColor(Color.WHITE);

This is the color of the background blur.

Can be determined by the color of views above it. Example, textviews with light color will need a darker blur color and vice versa. Note: blur color takes int.

Blur opacity

set as:

blurLayout.blurOpacity(0.3f);

Determines the opacity of the blurry backgroud. Higher values mean the blur color is more visible and vice versa. It takes float

Coded with ๐Ÿ’™ by revosleap.

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.