4

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

TheHardRock
  • 691
  • 7
  • 17
  • Firstly, you did not tell us what ~"**the white part**" is. Is it a TextView, an EditText, a custom View, or what? In any case, any View can be made to have a translucent background on Android with the `background` property. – IgorGanapolsky Sep 07 '16 at 20:33
  • http://stackoverflow.com/questions/36305283/how-to-make-translucent-activity – Mangesh Nov 18 '16 at 17:35

2 Answers2

4

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>
Meenal
  • 2,879
  • 5
  • 19
  • 43
  • java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.h8pathak.dash/com.example.h8pathak.dash.AnswerPost}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. What should I do? – TheHardRock Mar 14 '16 at 12:32
  • I have shared it now. – TheHardRock Mar 14 '16 at 17:57
  • Why is **NoTitleBar.Fullscreen** necessary? I think that is only relevant to Activities containing a Toolbar... – IgorGanapolsky Sep 07 '16 at 21:33
3

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..

IgorGanapolsky
  • 26,189
  • 23
  • 116
  • 147
Harry Sharma
  • 2,190
  • 2
  • 15
  • 41