|
在A activity中按钮B后弹出 C activity,C是以Dialog形式弹出的,但是弹出后是居中的,请问如何修改?重修dialog的话设置什么属性能不居中? |
|
|
自定义dialog
|
|
|
然后呢? |
|
|
C Activity实在声明文件中声明为android:theme=”@style/FunctionDialog” ,不知道设置什么属性可以让C Activity不居中而局右
|
|
Dialog dialog = getDialog();
Window window = dialog == null ? null : dialog.getWindow();
if (dialog != null && window != null) {
LayoutParams attr = window.getAttributes();
if (attr != null) {
attr.height = android.view.ViewGroup.LayoutParams.MATCH_PARENT;
attr.gravity = Gravity.RIGHT;
}
}
|
|
fanhui.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent function = new Intent();
function.setClass(UserJiuGongGeActivity.this, FunctionActivity.class);
startActivity(function);
}
});
dialog是Activity,是由intent启动的,没办法用你那个方法啊? |
|
|
那就更省事儿了
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().getAttributes().width = LayoutParams.WRAP_CONTENT;
getWindow().getAttributes().gravity = Gravity.RIGHT;
}
|
|
|
大神给跪了,太NB了,我查了一下午的问题让你轻松解决了! |
|
| 40分 |
刚好做过而已
|
|
只加这句 getWindow().getAttributes().gravity = Gravity.RIGHT; 即可,
getWindow().getAttributes().width = LayoutParams.WRAP_CONTENT; 可以省略 |
|