4

Hellow, I'm trying to create the translucent Activity and define the code in styles.xml but i'm unable to make my activity Translucent. how can i make it translucent can anybody help? my code of styles.xml is posted below.

<resources>

<!-- Base application theme. -->
<style name="TaxiTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="TaxiTheme.NoActionBar.FullScreen" parent="TaxiTheme">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

<style name="TaxiTheme.NoActionBar" parent="TaxiTheme">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
</style>

<color name="transparent_color">#129049</color>

<style name="Theme.Transparent" parent="TaxiTheme">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="android:windowBackground">@color/transparent_color</item>
    <item name="android:windowIsTranslucent">true</item>
</style>

Nabin Khatiwada
  • 478
  • 5
  • 15

1 Answers1

4

Apply this theme to the required Activity

<style name="Theme.TransparentInfo" parent="android:Theme">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@color/semiTransparentBlack</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowIsFloating">false</item>
        <item name="android:backgroundDimEnabled">true</item>
    </style>

value for @color/semiTransparentBlack is #00000000

Sreehari
  • 5,621
  • 2
  • 25
  • 59
  • 1
    sorry brother it is not working :( the app is crashing on starting the activity.The error message is : You need to use a Theme.AppCompat theme (or descendant) with this activity. – Nabin Khatiwada Mar 30 '16 at 09:59
  • 1
    Extend your Activity with just "extends Activity" , it will work :) – Sreehari Mar 30 '16 at 10:00
  • 1
    thank you ..it worked .i have replaced parent="TaxiTheme" in place of "android:theme" and extended AppCompactActivity and added @android:color/transparent – Nabin Khatiwada Mar 30 '16 at 10:22