Created
June 26, 2014 17:08
-
-
Save Cheesebaron/18d2b8b6f0d4757e35f6 to your computer and use it in GitHub Desktop.
DialogActivity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Activity(Label = "DialogActivity", Theme = "@style/PopupTheme")] | |
public class DialogActivity : Activity | |
{ | |
protected override void OnCreate (Bundle bundle) | |
{ | |
base.OnCreate (bundle); | |
ShowAsPopup(this, Resource.Layout.Main); | |
} | |
public override bool OnCreateOptionsMenu (IMenu menu) | |
{ | |
MenuInflater.Inflate(Resource.Menu.dialog_menu, menu); | |
return base.OnCreateOptionsMenu (menu); | |
} | |
public void ShowAsPopup(Activity activity, int resId) | |
{ | |
activity.RequestWindowFeature(WindowFeatures.ActionBar); | |
activity.Window.SetFlags(WindowManagerFlags.DimBehind, WindowManagerFlags.DimBehind); | |
var param = activity.Window.Attributes; | |
param.Height = 400; | |
param.Width = 300; | |
param.Alpha = 1.0f; | |
param.DimAmount = 0.5f; | |
activity.Window.Attributes = param; | |
SetContentView(resId); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<resources> | |
<style name="PopupTheme" parent="android:Theme.Holo.Light.Dialog"> | |
<item name="android:windowIsFloating">false</item> | |
<item name="android:windowContentOverlay">@null</item> | |
<item name="android:windowSoftInputMode">stateAlwaysHidden</item> | |
<item name="android:windowActionModeOverlay">true</item> | |
<item name="android:windowIsTranslucent">true</item> | |
</style> | |
</resources> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment