Android : Android FrameLayout foreground setAlpha not working

on Monday, October 6, 2014


I found this most excellent solution to the exact issue I am trying to solve here:


Blur or dim background when Android PopupWindow active


However, I cannot get the parent view to dim by setting the Alpha. I am using a rectangle shape as the solution suggests The Drawable is a GradientDrawable. Here's the code I'm using:



@Override
public void onViewPhoto(PostObject item) {
rootView.getForeground().setAlpha(220);
rootView.invalidate();
PhotoPopup pp = new PhotoPopup(getActivity(), rootView, item.getObject_Id());
pp.show();
rootView.getForeground().setAlpha(0);
rootView.invalidate();
}


I've tried this on both KitKat (Asus Memo Pad) and JellyBean (Samsung Galaxy Tab 2) Any ideas?


For completeness: Here's the Layout



<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/streamList_rootFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foreground="@drawable/shape_dim_window" >

<ListView
android:id="@+id/streamList_listview"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>

</FrameLayout>


And the shape itself:



<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#000000" />
</shape>

0 comments:

Post a Comment