自定义AlertDialog,去掉黑色边框

1:实现方法
	private void showCancelDialog() {
		// TODO Auto-generated method stub
		 AlertDialog.Builder builder=new AlertDialog.Builder(this);
		dialog=builder.create();
		dialog.show();
		final Window window = dialog.getWindow();
		window.setContentView(R.layout.dialog_cancel);
		 Button cancelBtn=(Button)window.findViewById(R.id.cancel_btn);
		 Button continueBtn=(Button)window.findViewById(R.id.continue_btn);
		 cancelBtn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
		});
		 continueBtn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				dialog.dismiss();
			}
		});

	}
2.对话框布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="270dp"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:background="@drawable/dialog_background"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="23dp"
        android:gravity="center"
        android:text="放弃创建店铺"
        android:textColor="#000000"
        android:textSize="18sp"
        android:textStyle="bold" />

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="18dp"
        android:layout_marginRight="18dp"
        android:layout_marginTop="12dp"
        android:text="第一个发现该店的人是你,真的要放弃创建店铺吗?"
        android:textColor="#454545"
        android:textSize="18sp" />

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_marginTop="25dp"
        android:layout_height="53dp"
        android:orientation="vertical"
        android:gravity="bottom" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="1px"
            android:background="@color/div_line_b" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="52dp"
            android:gravity="center" >

            <Button
                android:id="@+id/cancel_btn"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:background="@null"
                android:text="放弃"
                android:textColor="#017aff"
                android:textSize="18sp" />
			<LinearLayout 
			    android:layout_width="1px"
			    android:layout_height="fill_parent"
			    android:background="@color/div_line_b"
			    ></LinearLayout>
            <Button
                android:id="@+id/continue_btn"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:background="@null"
                android:text="继续创建"
                android:textColor="#017aff"
                android:textSize="18sp" />
        </LinearLayout>
    </LinearLayout>

</LinearLayout>


3:对话框背景

<?xml version="1.0" encoding="utf-8"?>  
<shape xmlns:android="http://schemas.android.com/apk/res/android" >  
  
    <solid android:color="#d8e0de" />  
  
    <stroke  
        android:width="1dp"  
        android:color="@color/div_line_b" />  
  
    <corners android:radius="10dp" />  
  
    <padding  
        android:bottom="0dp"  
        android:left="0dp"  
        android:right="0dp"  
        android:top="0dp" />  
</shape>  
<img src="https://img-blog.csdn.net/20150203105558087?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbGlhbndhbmZlaQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值