get Rect Outline as ViewOutlineProvider - Android User Interface

Android examples for User Interface:View Property

Description

get Rect Outline as ViewOutlineProvider

Demo Code


//package com.java2s;
import android.graphics.Outline;
import android.graphics.Rect;

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

public class Main {
    public static ViewOutlineProvider getRectOutline(final Rect rect) {
        return new ViewOutlineProvider() {
            @Override/*from   w  ww .  ja v a  2 s  . c  o  m*/
            public void getOutline(View view, Outline outline) {
                outline.setRect(rect);
            }
        };
    }

    public static ViewOutlineProvider getRectOutline() {
        return new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setRect(0, 0, view.getMeasuredWidth() / 2,
                        view.getMeasuredHeight());
            }
        };
    }
}

Related Tutorials