在自定义Dialog时显示的界面中老是有黑色的边框,下面就介绍使用style去除黑色边框方法。
首先在values/styles定义自定义样式:
- @drawable/actionbar_item_background
这个是重点,只有添加了这个后才能去除黑色的边框
或者是自定义一个透明的背景图片,这样也可以去除黑色边框!
代码:
static class MsgDialog extends Dialog implements
android.view.View.OnClickListener {
private String text;
public MsgDialog(Context context, String text) {
super(context, R.style.MyDialog);
this.text = text;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login_dialog);
TextView txt = (TextView) findViewById(R.id.login_dialog_txt);
txt.setText(text);
TextView confirm = (TextView) findViewById(R.id.login_dialog_btn);
confirm.setOnClickListener(this);
}
@Override
public void onClick(View v) {
MsgDialog.this.dismiss();
}
}
xml:
--------------------------------------------------------------------------华丽丽的分割线-------------------------------------------------------------------------
dialog自定义动画:
1、在style.xml中添加
2、anim/enter.xml
anim/exit.xml
3、在代码中
在DialogFragment的方法onCreateDialog中使用
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(),
R.style.AA);
dialg自定义动画,ok