Android 如何使我的对话框在宽度上成为填充父对话框
如何在android中使对话框同时适合屏幕的左、右和下角Android 如何使我的对话框在宽度上成为填充父对话框,android,android-layout,android-dialog,Android,Android Layout,Android Dialog,如何在android中使对话框同时适合屏幕的左、右和下角 googleMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker arg0) { googleMap.getUiSettings().setMapToolba
googleMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker arg0) {
googleMap.getUiSettings().setMapToolbarEnabled(true);
final Dialog dialog = new Dialog(getActivity());
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.mapdialogbox);
// dialog.setCanceledOnTouchOutside(false);
Window window = dialog.getWindow();
WindowManager.LayoutParams wlp = window.getAttributes();
wlp.gravity = Gravity.BOTTOM ;
wlp.width = LinearLayout.LayoutParams.FILL_PARENT;
wlp.x = -100;
dialog.show();
}
});
但是我想把我的对话框附在角落里,我怎样才能实现它呢?我做了我的代码:你必须创建自定义样式并将其设置为你的对话框。
Try this , may be its helpful for U.
wlp.width = WindowManager.LayoutParams.MATCH_PARENT;
wlp.height = WindowManager.LayoutParams.WRAP_CONTENT;
以下是我的代码:
最终对话框=新对话框(上下文,R.style.CustomDialog);对话框.requestWindowFeature(窗口.FEATURE\u无\u标题);dialog.getWindow().setLayout(ViewGroup.LayoutParams.FILL\u父级,在此处输入代码ViewGroup.LayoutParams.FILL\u父级);LayoutFlater充气器=(LayoutFlater)context.getSystemService(context.LAYOUT\u充气器\u服务);视图=充气机。充气(R.layout.full\u screen\u dialog,null);cancel.setOnClickListener(new View.OnClickListener()@覆盖公共void onClick(视图v){dialog.discouse(); }); setContentView(视图);对话框。可设置可取消(false);dialog.show();
下面是R.style.CustomDialog:
真的
@android:彩色/黑色
80dp
@空的
真的
假的
假的
快乐密码:我希望它能帮助你`
我完成了我的代码:您必须创建自定义样式并将其设置为对话框。
以下是我的代码:
最终对话框=新对话框(上下文,R.style.CustomDialog);对话框.requestWindowFeature(窗口.FEATURE\u无\u标题);dialog.getWindow().setLayout(ViewGroup.LayoutParams.FILL\u父级,在此处输入代码ViewGroup.LayoutParams.FILL\u父级);LayoutFlater充气器=(LayoutFlater)context.getSystemService(context.LAYOUT\u充气器\u服务);视图=充气机。充气(R.layout.full\u screen\u dialog,null);cancel.setOnClickListener(new View.OnClickListener()@覆盖公共void onClick(视图v){dialog.discouse(); }); setContentView(视图);对话框。可设置可取消(false);dialog.show();
下面是R.style.CustomDialog:
真的
@android:彩色/黑色
80dp
@空的
真的
假的
假的
快乐密码:我希望它能帮助你`
在对话框生成器的方法的SetView()
上设置父视图。
然后添加一个子项到设备屏幕的宽度
View view = createPopView();
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setCancelable(true).setView(view);
private View createPopView() {
LinearLayout layout = new LinearLayout(context);
layout.setOrientation(LinearLayout.VERTICAL);
EditText editText = new EditText(context);
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(screen_width,-2);
layout.addView(editText);
return layout;
}
在DialogBuilder
的SetView()方法上设置父视图。
然后添加一个子项到设备屏幕的宽度
View view = createPopView();
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setCancelable(true).setView(view);
private View createPopView() {
LinearLayout layout = new LinearLayout(context);
layout.setOrientation(LinearLayout.VERTICAL);
EditText editText = new EditText(context);
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(screen_width,-2);
layout.addView(editText);
return layout;
}
删除版面上的所有填充。删除版面上的所有填充。试试这个
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_layout);
getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
}
试试这个
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_layout);
getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
}
填充父对象已弃用…您应该使用匹配父对象您的问题是该视图和角点之间的间隙?填充父对象已弃用…您应该使用匹配父对象您的问题是该视图和角点之间的间隙?