set View to Drawable Background - Android Graphics

Android examples for Graphics:Background Drawable

Description

set View to Drawable Background

Demo Code


//package com.java2s;

import android.graphics.drawable.Drawable;

import android.os.Build;

import android.view.View;

public class Main {
    @SuppressWarnings("deprecation")
    public static void setBackGround(View view, Drawable drawable) {
        if (Build.VERSION.SDK_INT >= 16)
            view.setBackground(drawable);
        else/*  w w  w.ja  v  a2s  .  c o m*/
            view.setBackgroundDrawable(drawable);
    }
}

Related Tutorials