У меня есть PreferenceFragemnt, и я хочу, чтобы в настройках был настроен волновой эффект. Итак, я начал создавать CostumPreference, но я не знаю, как установить фон для рисования. Я нашел этот пост . Но это не работает для меня.
Есть моя CostumPreference:
public class RipPreference extends Preference {
private Context ctx;
public RipPreference(Context context, AttributeSet attrs) {
super(context, attrs);
ctx = context;
}
public RipPreference(Context context) {
super(context);
ctx = context;
}
//This event won't be tiggered
protected View onCreateView(ViewGroup parent) {
//Preference is not an View so there is no onCreateView
View view = super.onCreateView(parent);
view.setBackground(<my ripple>);
return view;
}
}
private void setCustomStyle(View view) {
RippleDrawable drawable = (RippleDrawable) ctx.getDrawable(R.drawable.settings_preference_background);
view.setBackground(drawable);
}
}
Возможно, у кого-то есть другая идея. :)