Giter Club home page Giter Club logo

roundedconerswithglide's Introduction

RoundedConersWithGlide

Rounded Coners With Glide

You'll find the supporting article for this project here!

How to use

Now We can specify corner, margin ,border color and border margin:

    public static int sCorner = 15;
    public static int sMargin = 20;

    public static int sBorder = 10;
    public static String sColor = "#7D9067";

Note: sMargin should be more or same than sBorder

We add the constructor with or without border:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ....

        // Rounded corners
        Glide.with(this).load("http://scareface.jpeg")
        .apply(RequestOptions.bitmapTransform(
        new RoundedCornersTransformation(this, sCorner, sMargin))).into(mImageView);
        
        // Rounded corners with border
        Glide.with(this).load("http://scareface.jpeg")
        .apply(RequestOptions.bitmapTransform(
        new RoundedCornersTransformation(this, sCorner, sColor, sBorder))).into(mImageViewBorder);
        
    }

*Rounded corners with border xml

In drawable folder We add this frame.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <solid android:color="@android:color/transparent" />
    <stroke
        android:width="15dp"
        android:color="#7D9067" />

    <corners android:radius="5dp" />
</shape>

In our layout, two elements:

<RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/circle"
        app:layout_constraintBottom_toTopOf="@+id/guideline"
        app:layout_constraintLeft_toLeftOf="@+id/guideline3"
        app:layout_constraintRight_toLeftOf="@+id/guideline3"
        app:layout_constraintTop_toTopOf="@+id/guideline">

        <ImageView
            android:id="@+id/imageViewBorderResizing"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:srcCompat="@mipmap/ic_launcher" />
</RelativeLayout>

In our Activity or fragment We can this parametres

public static int sCorner = 15;
public static int sMargin = 0;

with this constructor:

Glide.with(this).load("http://thedeveloperworldisyours.com/wp-content/uploads/scareface.jpeg").apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(this, sCorner, sMargin))).into(mImageViewBorderResizing);

Also visit my blog: The developer world is yours

The developer world is yours

Requirements

- Android Studio

- Gradle

Installation

- Install Android Studio:

https://developer.android.com/sdk/installing/index.html

- Install gradle:

http://gradle.org/docs/current/userguide/installation.html

Usage

Compile with Android Studio and gradle

Feel free to contribute, and contact me for any issues.

Developed By

Add me to Linkedin

License

Copyright 2017 Javier González Cabezas

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.

roundedconerswithglide's People

Contributors

javiergonzal avatar

Watchers

 avatar  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.