I would like to do the same effect with linearlayout like when you call showDialog. It is easy to disable all components of linear layout, but how can I change the color?
Is it possible to throw some shadow on layout?
Thank you for answer.
I would like to do the same effect with linearlayout like when you call showDialog. It is easy to disable all components of linear layout, but how can I change the color?
Is it possible to throw some shadow on layout?
Thank you for answer.
Thanks to Asok advice I found this:
It is working correct for me.
The way how I setClickable to ALL child:
TraverseChildren(GetChildren(_llRest), false);
where
private void TraverseChildren(ArrayList<View> childrenList, boolean b) {
for (View view : childrenList) {
view.setClickable(b);
view.setEnabled(b);
if (view instanceof ViewGroup)
TraverseChildren(GetChildren((ViewGroup)view), b);
}
}
private ArrayList<View> GetChildren(ViewGroup view) {
ArrayList<View> children = new ArrayList<View>();
for (int i = 0; i < view.getChildCount(); i++)
if (view.getChildAt(i) != null)
children.add(view.getChildAt(i));
return children;
}
I don't think I understood well what you want to do. If you just want to change the color of the layout you can do it in the XML declaration using the android:background
attribute or programmatically using the method setBackground
or setBackgroundResource
on your layout object. If you want to make the activity that you are going to display look somewhat like a dialog (with a translucent background and such) the easiest way is to leave everything on that layout like you would normally do and apply a theme to the activity on the manifest:
<activity android:theme="@android:style/Theme.Dialog">
You can setAlpha
to the parent to apply a transparency to all of the Views children.
Here is an example of the approach I took when I created a View to overlay my primary layout:
RelativeLayout mainRelativeLayout = (RelativeLayout)findViewById(R.id.mainlayout);
mainRelativeLayout.setAlpha((float).45);
My mainRelativeLayout
, in this case, contains many ImageViews
and TextViews
which all inherited the transparency. Which gave me the effect of having a shadow.
setAlpaha
of the View
class is only supported for API 11+ or Platform Version / Android OS Ver 3.0+