android 自己定义Dialog去除黑色边框
在自己定义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:
> <LinearLayout xmlns:andro android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="5dp" android:background="#FFF" android:orientation="vertical" > <TextView android: android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="center" android:text="TextView" android:textColor="@color/grey3" android:textSize="18sp" /> <!-- 切割线 --> <View android: style="@style/Viewborder" /> <TextView android: android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:height="50dp" android:text="确定" android:textColor="@color/grey3" android:textSize="20sp" /> </LinearLayout>
--------------------------------------------------------------------------华丽丽的切割线-------------------------------------------------------------------------
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.xml3、在代码中
在DialogFragment的方法onCreateDialog中使用
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AA);
dialg自己定义动画,ok