TheHardRock
TheHardRock

Reputation: 691

How to make the background of an activity translucent?

I want the white part in this activity to be translucent so that I could partially see the activity below this. This activity uses multiple nested LinearLayouts (ie. One Linear Layout having the red background is inside a Linear Layout with the white background). How can I accomplish this?

enter image description here

This is my AndroidManifest.xml file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.h8pathak.dash">

    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:name="com.example.h8pathak.dash.app.AppController"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".activity.LoginActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        <activity android:name=".activity.RegisterActivity"/>
        <activity android:name=".MainActivity"/>
        <activity android:name=".feed.NewsFeed"/>
        <activity android:name=".feed.NewPost"/>
        <activity android:name=".AnswerPost"
            android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>
            <!--android:theme="@android:style/Theme.Translucent.NoTitleBar"-->

    </application>

</manifest>

The activity I'm working on is .AnswerPost

Upvotes: 4

Views: 5008

Answers (2)

Harry Sharma
Harry Sharma

Reputation: 2200

You can follow the following two steps

1.In your activity

 requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setBackgroundDrawable(
            new ColorDrawable(android.graphics.Color.TRANSPARENT));

    setContentView(R.layout.alarmring);
  1. In your manifest

    <activity
        android:name="com.calender.alarms.alarm_interfac_adapter_alarm"
        android:screenOrientation="portrait"
        android:theme="@android:style/Theme.Translucent" >
    </activity>
    

let me know if you need any assistance in this. Mark this up if it helps..

Upvotes: 3

Meenal
Meenal

Reputation: 2877

You can create a transparent activity with the help of

1.Make the background of layout in your xml file transparent by using

android:background="@android:color/transparent"

2.And also,make the theme in your manifest file transparent for that particular acitivity

   <activity
        android:name="Your activity"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" >
    </activity>

Upvotes: 4

Related Questions