The idea is to declare a standard Activity to make it appear like a Popup window of sorts.
Use this code (standard boiler plate Intent
code to trigger the Activity
)
SOME_WIDGET.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent myIntent = new Intent(getApplicationContext(), THE_POPUP_ACTIVITY.class);
startActivity(myIntent);
}
});
If, for example, you name the popup Activity
as Popup, then replace the THE_POPUP_ACTIVITY.class
with Popup.class
Now, for this Activity, in the Manifest, declare a theme
. For example:
And this is the corresponding style declaration:
<style name="DialogNoTitleBar" parent="android:style/Theme.Dialog">
<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:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
Also, in the onCreate()
of the Popup Activity, you might want to add this statement right after the setContentView(R.layout.THE_LAYOUT_XML);
I say might because how you want it to appear may vary from how I program my popup Activity.
getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);