在自定义Dialog时显示的界面中老是有黑色的边框,下面就介绍使用style去除黑色边框方法。


首先在values/styles定义自定义样式:



或者是自定义一个透明的背景图片,这样也可以去除黑色边框!

代码:

	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

<scale
        android:fromXScale="50%"
        android:fromYScale="50%"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="100%"
        android:toYScale="100%" >
    </scale>

  anim/exit.xml

3、在代码中

在DialogFragment的方法onCreateDialog中使用

AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(),
				R.style.AA);

dialg自定义动画,ok


相关文章:

  • 2022-12-23
  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
  • 2021-09-30
  • 2021-12-19
  • 2021-10-10
猜你喜欢
  • 2021-09-28
  • 2022-12-23
  • 2021-08-07
  • 2021-09-25
  • 2021-09-12
  • 2021-08-07
  • 2022-01-04
相关资源
相似解决方案