I found a description about the difference of transparent and translucent. These are the important parts:
What does translucent mean? If you were writing about a pane of glass, but that pane of glass was frosty, darkly colored, or very dirty, you would use translucent.
What does transparent mean? If you were writing about a pane of glass, and that piece of glass was perfectly clear, you would use transparent. Something that is transparent allows all light to pass through it. Clean air and the windshield of a car are transparent.
If you want to understand this deeply then look here.
I want to make a ViewGroup translucent in Android. In a video I found how to make an Activity translucent. What they do is defining the following styles and colors:
<color name="transparent_green_color">#8800ff00</color>
<style name="TranslucentGreen" parent="android:Theme.Translucent">
<item name="android:windowBackground">@color/transparent_green_color</item>
</style>
And then in the manifest the within the application tag they add this new style as a theme:
<application
android:theme="@style/TranslucentGreen"
...>
...
</application>
What I want to do is NOT to make an Activity
translucent but to make a ViewGroup
translucent.
My layout is structured like this:
<FrameLayout>
<RelativeLayout>
...
</RelativeLayout>
<RelativeLayout>
...
</RelativeLayout>
</FrameLayout>
The second RelativeLayout
shall be translucent and the first one shall be visible a bit through the translucent RelativeLayout
. How to do that?
Using the Blurry library solved my problem. So if the second ViewGroup (in my case second RelativeLayout
) has to be at the top and the first one has to shine through translucent, then you need to call something like:
Blurry.with(context).radius(25).sampling(2).onto(viewGroup);
and then you have the desired effect. For going back to the old view state without translucency you can just use this method:
Blurry.delete(viewGroup)
on the desired view. I like that library because it's very compact.
If you are not able to use external libraries you should maybe start with this Medium article. It works with RenderScript and Bitmap class. Bu It shall be possible to create Bitmaps from ViewGroups.