Android examples for User Interface:Layout
set Ripple Background Effect for FrameLayout
//package com.java2s; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.os.Build; import android.widget.FrameLayout; public class Main { public static void setRippleBackgroundEffect(FrameLayout view) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int[] attrs = new int[] { android.R.attr.selectableItemBackground }; TypedArray ta = view.getContext().obtainStyledAttributes(attrs); Drawable drawable = ta.getDrawable(0 /* index */); ta.recycle();/* w w w .jav a 2s . c o m*/ view.setForeground(drawable); } } }