Android examples for User Interface:View Padding
update Background View Resource With Retained Padding
//package com.java2s; import android.view.View; public class Main { public static void updateBackgroundResourceWithRetainedPadding( View view, int resourceID) { int bottom = view.getPaddingBottom(); int top = view.getPaddingTop(); int right = view.getPaddingRight(); int left = view.getPaddingLeft(); view.setBackgroundResource(resourceID); view.setPadding(left, top, right, bottom); }// ww w . jav a 2s . c om }