Android Activity Invisible by Default

2020-03-18 08:37发布

问题:

I have an activity defined like this

<activity android:name=".queue.ItemDetailActivity" 
    android:theme="@android:style/Theme.Dialog"></activity>

This activity implements runnable and shows a progress bar while data is retrieved from the server. I would like to have the dialog invisible until the data is loaded. Is there a way for the activity to start invisible and then later use setVisible(true); to make it appear?

回答1:

Try this style for the activity.

<style name="Invisible" parent="@android:style/Theme.Dialog">
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowContentOverlay">@null</item>
</style>