Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Outline;
import android.os.Build;

import android.view.View;
import android.view.ViewOutlineProvider;

public class Main {
    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    public static void makeCircle(final View view, final int dimenResId) {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            ViewOutlineProvider viewOutlineProvider = new ViewOutlineProvider() {
                @Override
                public void getOutline(View view, Outline outline) {
                    Context context = view.getContext();
                    int size = context.getResources().getDimensionPixelSize(dimenResId);
                    outline.setOval(0, 0, size, size);
                }
            };

            view.setOutlineProvider(viewOutlineProvider);
        }
    }
}