java - Android darken background -
does know how programmatically darken view's
background alertdialog
or navigationdrawer
doing it? need background overlaps toolbar
(1) , statusbar
, icons statusbar
should visible(2). in case should not dialog
. example, had darken background around button
or customview
.
i looking answer question long time, found solution.
i researched code "dialogplus" library , find out key point.
getwindow().getdecorview();
final layoutinflater inflater = (layoutinflater) getsystemservice(layout_inflater_service); final view background = inflater.inflate(r.layout.frame, null); final animation = animationutils.loadanimation(this, r.anim.in); fab.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { viewgroup decorview = (viewgroup) getwindow().getdecorview().findviewbyid(android.r.id.content); decorview.addview(background); background.startanimation(a); } });
background resoource file:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <framelayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/black" android:alpha="0.5"></framelayout> </linearlayout>
Comments
Post a Comment