How to display transparent activity on the another activity without removing previous activity

前端 未结 3 1568
你的背包
你的背包 2020-12-25 12:53

How to display transparent activity on the another activity without removing previous activity ?

I am able to create transparent activity but when i trying to push i

相关标签:
3条回答
  • 2020-12-25 13:35

    declare your activity in manifest like this

     <activity android:name=".yourActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>
    

    and add a transperent background to your layout like this

     <?xml version="1.0" encoding="utf-8"?>
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
      android:background = "any tranparent image name"  >
     </RelativeLayout>
    

    Edit:

    i think you are using this to open your transparent activity it finish your previous activity

    Intent intent =new Intent(mContext,yourNewActivity.class);
    startActivity(intent);
    finish();
    

    remove finish from here then your new activity in on top of previous activity like this

     Intent intent =new Intent(mContext,yourNewActivity.class);
     startActivity(intent);
    

    Hope help..

    0 讨论(0)
  • 2020-12-25 13:57

    For the AppCompat style, you can use the following code in your styles.xml, and the add that in your manifest.

    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>
    

    Manifest

    <activity android:name=".HomeActivity"
    android:theme="@style/Theme.Transparent" />
    
    0 讨论(0)
  • 2020-12-25 13:57

    I don't know why would you want that, but maybe a Custom dialog can do what you are looking for.

    EDIT: This question has been answered before: How do I create a transparent Activity on Android?

    I don't want to be rude, but I think you should do more research from your part. Also, can you post some code to see what exactly are you trying out, it also shows that you are trying something.

    0 讨论(0)
提交回复
热议问题