Midhilaj
Midhilaj

Reputation: 4987

How to make android layout background transparent?

Make android layout background transparent

How to make RecyclerView item background transparent I need to show background image?

I tried 3 solutions given in Stack Overflow and not worked for me

1 : android:background="?android:attr/selectableItemBackground"<br>
2 : android:background="@android:color/transparent"<br>
3 : alpfha 0.4

udated i also tried
4: android:background="@null" (Answer from this post) and not working

full xml code

Upvotes: 1

Views: 22816

Answers (6)

user14113266
user14113266

Reputation:

set transparent color in your view

#80000000

Upvotes: 0

Drashti Joshi
Drashti Joshi

Reputation: 376

Try to give this on your item CardView

 app:cardBackgroundColor="@android:color/transparent"

Upvotes: 15

tj2611
tj2611

Reputation: 327

set all layout backgrouncolor= '#00000000' also to your Recycleview background color to achieve this view

Upvotes: 0

Dipin P J
Dipin P J

Reputation: 58

First add this style in styles.xml

<style name="Theme.Transparent" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:backgroundDimEnabled">true</item>
    <item name="colorPrimaryDark">@android:color/transparent</item>
</style>

then add this line in AndroidManifest.xml below the corresponding activity

android:theme="@style/Theme.Transparent"/>

hope it helps.

Upvotes: 0

Android Geek
Android Geek

Reputation: 9225

Try this:

1) In your manifest make that activity theme to Transparent-

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androidhub4you.transparent.background"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="18" />

<application
    android:allowBackup="true"
    android:icon="@drawable/logo"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.androidhub4you.transparent.background.MainActivity"
        android:theme="@android:style/Theme.transparent"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

2) Now your page will be 100% transparent, so if you need some background color then set opacity like-

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#80000000"
tools:context=".MainActivity" >

it helps you.

Upvotes: 1

Zachary Sweigart
Zachary Sweigart

Reputation: 1111

So for the layout you are inflating for the item you can use android:background="@null"

You can also use developer options on your device to see layout bounds or check the view hierarchy to see which item is giving you problems

Upvotes: 0

Related Questions