There is one normal Question,
If need to put a background image in an activity and this image needs to be a bit transparent and want to put text over it. how can this be done? can it be done directly on the xml file and if yes how? Is it also possible to do it programmatically and if yes how?
Answers
You can embed the image in xml, so you'll be able to see it in the Graphical Layout
<LinearLayout
style="@style/LoginFormContainer"
android:id="@+id/login_layout"
android:orientation="vertical"
android:background="@drawable/signuphead">
style="@style/LoginFormContainer"
android:id="@+id/login_layout"
android:orientation="vertical"
android:background="@drawable/signuphead">
And change the code like this to make it transparent:
Drawable loginActivityBackground = findViewById(R.id.login_layout).getBackground();
loginActivityBackground.setAlpha(127);
loginActivityBackground.setAlpha(127);
(// some value 0-255 where 0 is fully transparent and 255 is fully opaque)
No comments:
Post a Comment