Android 如何在操作栏下方显示对话框?
我想在操作栏下面显示对话框。但对话框以全屏显示。也就是说,对话框覆盖了操作栏的位置。所以我不能在动作栏里做任何动作。如何克服这个问题?Android 如何在操作栏下方显示对话框?,android,Android,我想在操作栏下面显示对话框。但对话框以全屏显示。也就是说,对话框覆盖了操作栏的位置。所以我不能在动作栏里做任何动作。如何克服这个问题? <style name="PopupTheme" parent="Theme.Sherlock"> <item name="android:windowFrame">@null</item> <item name="android:windowIsFloating">false</it
<style name="PopupTheme" parent="Theme.Sherlock">
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
<item name="android:windowSoftInputMode">stateAlwaysHidden</item>
<item name="android:windowActionModeOverlay">true</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowCloseOnTouchOutside">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="windowContentOverlay">@null</item>
</style>.
private void showAsPopup(SherlockActivity activity) {
//To show activity as dialog and dim the background, you need to declare android:theme="@style/PopupTheme" on for the chosen activity on the manifest
//activity.requestWindowFeature(Window.FEATURE_ACTION_BAR); // NO NEED to call this line.
activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND,
WindowManager.LayoutParams.FLAG_DIM_BEHIND);
LayoutParams params = activity.getWindow().getAttributes();
params.alpha = 1.0f;
params.dimAmount = 0.5f;
activity.getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
// This sets the window size, while working around the IllegalStateException thrown by ActionBarView
activity.getWindow().setLayout(width,height);
}
@空的
假的
@空的
@android:style/Animation.Dialog
州政府
真的
@空的
真的
真的
@空的
.
私人void showAsPopup(夏洛克活动){
//要将活动显示为对话框并使背景变暗,您需要为清单上选定的活动声明android:theme=“@style/PopupTheme”处于启用状态
//activity.requestWindowFeature(Window.FEATURE_ACTION_BAR);//无需调用此行。
activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG\u DIM\u后面,
WindowManager.LayoutParams.FLAG_DIM_BEHIND);
LayoutParams params=activity.getWindow().getAttributes();
参数α=1.0f;
参数dimAmount=0.5f;
activity.getWindow().setAttributes((android.view.WindowManager.LayoutParams)参数);
//这将设置窗口大小,同时处理ActionBarView引发的IllegalStateException
activity.getWindow().setLayout(宽度、高度);
}
添加解释怎么样?