Skip to content
Rounded coners with Glide, also you can to put a frame, border.
Java
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea update new version Nov 10, 2018
app
gradle/wrapper update version 4 Aug 23, 2017
.gitignore update version 4 Aug 23, 2017
README.md Update README.md Nov 7, 2017
RoundedConersWithGlideV4.png added image Sep 6, 2017
build.gradle update new version Nov 10, 2018
gradle.properties update version 4 Aug 23, 2017
gradlew update version 4 Aug 23, 2017
gradlew.bat update version 4 Aug 23, 2017
settings.gradle update version 4 Aug 23, 2017

README.md

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.
You can’t perform that action at this time.