user3521259
user3521259

Reputation:

How to make a background image transparent in the activity?

I want to use an Activity which has normal views and controls.

I made the background of it as an image and I can't make this image transparent Here's my code :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/honey"
 >
</RelativeLayout>

I want just the image to be transparent

Upvotes: 2

Views: 1892

Answers (1)

try this for transparent background:

in the file AndroidManifest.xml

<activity android:name="YourActivity" android:theme="@style/TransparentStyle"></activity>

in the file /res/values/style.xml

<resources>
  <style name="TransparentStyle">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item>
    <item name ="android:windowBackground">#00000000</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:colorForeground">#ffffff</item>
  </style>
</resources>

and try this for transparent image:

<ImageView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:src="@drawable/yourImage"
  android:alpha=".75"/>

Upvotes: 1

Related Questions