android圆角背景dialog

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >


    <solid android:color="#ffffff" />


    <corners android:radius="6dp" />


</shape>



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="vertical" >


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="120dp"
        android:background="@drawable/alert_dialog_bg" >


        <TextView
            android:id="@+id/sy_payui_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="25dp"
            android:text="@string/sy_alert_confirm_tip_message"
            android:textColor="#262626"
            android:textSize="16dp" />


        <View
            android:id="@+id/sy_update_line"
            android:layout_width="match_parent"
            android:layout_height="0.5dp"
            android:layout_below="@+id/sy_payui_text"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:layout_marginTop="16dp"
            android:background="#d8d8d8" />


        <Button
            android:id="@+id/sy_payui_determine"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/sy_update_line"
            android:layout_marginRight="32dp"
            android:layout_marginTop="16dp"
            android:background="@android:color/transparent"
            android:padding="5dp"
            android:text="@string/alert_dialog_finish"
            android:textColor="#06a303"
            android:textSize="16dp" />


    </RelativeLayout>


</LinearLayout>


public class SyConfirmCustomDialog extends Dialog {


public SyConfirmCustomDialog(Context context) {
super(context);
}


public SyConfirmCustomDialog(Context context, int theme) {
super(context, theme);
}


public static class Builder {
private Context context;


private DialogInterface.OnClickListener positiveButtonClickListener;


public Builder(Context context) {
this.context = context;
}


/**
* Set the positive button resource and it's listener

* @param positiveButtonText
* @return
*/
public Builder setPositiveButton(DialogInterface.OnClickListener listener) {
this.positiveButtonClickListener = listener;
return this;
}


public SyConfirmCustomDialog create() {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final SyConfirmCustomDialog dialog = new SyConfirmCustomDialog(context,
CPResourceUtil.getStyleId(context, "sy_pay_custom_dialog"));
View layout = inflater.inflate(CPResourceUtil.getLayoutId(context, "sy_payui_confirm_dialog"), null);
dialog.addContentView(layout, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
// dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
if (positiveButtonClickListener != null) {
((Button) layout.findViewById(CPResourceUtil.getId(context, "sy_payui_determine")))
.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
positiveButtonClickListener.onClick(dialog, DialogInterface.BUTTON_POSITIVE);
}
});
}


dialog.setContentView(layout);
return dialog;
}


}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值