简体   繁体   中英

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

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"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM