今天遇到一个大难题哦,不过有大牛一眼就瞄出来了,然后就解决了,AlertDialog和Dialog自定义后圆角的处理,如果你跟我一样没有看到这些细节的话就栽了,用AlertDialog不能使得圆角背景透明化,所以要用Dialog处理才行,也就是下面的方法。

    Dialog:

private static Dialog mDialog;

	// 加载gridview中的item的xml方法
	public static View getView(Context context, int layoutId) {
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View layout = inflater.inflate(layoutId, null);
		return layout;
	}
/**
	 * 显示自定义对话框
	 * 
	 * @param context
	 * @param message
	 * @param listener
	 */
	public static void showDialog(final Context context, String message,
			final IAlertDialogButtonListener listener) {
		View dialogView = null;
		// Dialog.Builder builder = new Builder(context,
		// R.style.Theme_Transparent);
		mDialog = new Dialog(context, R.style.Theme_Transparent);

		dialogView = getView(context, R.layout.dialog_view);
		Button btn_ok = (Button) dialogView.findViewById(R.id.btn_ok);
		Button btn_cancel = (Button) dialogView.findViewById(R.id.btn_cancel);
		TextView txt_dailog_message = (TextView) dialogView
				.findViewById(R.id.txt_dailog_message);
		txt_dailog_message.setText(message);
		btn_ok.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// 关闭dialog
				if (mDialog != null) {
					mDialog.cancel();
				}
				// 事件回调
				if (listener != null) {
					listener.onClick();
				}

				// 播放音效
				// MyPlayer.playTone(context, MyPlayer.INDEX_STONE_ENTER);
			}
		});
		btn_cancel.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// 关闭dialog
				if (mDialog != null) {
					mDialog.cancel();
				}
				// 播放音效
				// MyPlayer.playTone(context, MyPlayer.INDEX_STONE_CANCEL);
			}
		});
		// 为dialog设置View
		// builder.setView(dialogView);
		mDialog.setContentView(dialogView);
		// mDialog = builder.create();
		mDialog.show();
	}
}

    AlertDialog:

/**
	 * 显示自定义对话框
	 * 
	 * @param context
	 * @param message
	 * @param listener
	 */
	public static void showDialog(final Context context, String message,
			final IAlertDialogButtonListener listener) {
		View dialogView = null;
		AlertDialog.Builder builder = new Builder(context,
				R.style.Theme_Transparent);
		dialogView = getView(context, R.layout.dialog_view);
		ImageButton btn_ok = (ImageButton) dialogView.findViewById(R.id.btn_ok);
		ImageButton btn_cancel = (ImageButton) dialogView
				.findViewById(R.id.btn_cancel);
		TextView txt_dailog_message = (TextView) dialogView
				.findViewById(R.id.txt_dailog_message);
		txt_dailog_message.setText(message);
		btn_ok.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// 关闭dialog
				if (mAlertDialog != null) {
					mAlertDialog.cancel();
				}
				// 事件回调
				if (listener != null) {
					listener.onClick();
				}

				// 播放音效
				MyPlayer.playTone(context, MyPlayer.INDEX_STONE_ENTER);
			}
		});
		btn_cancel.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// 关闭dialog
				if (mAlertDialog != null) {
					mAlertDialog.cancel();
				}
				// 播放音效
				MyPlayer.playTone(context, MyPlayer.INDEX_STONE_CANCEL);
			}
		});
		// 为dialog设置View
		builder.setView(dialogView);
		mAlertDialog = builder.create();
		mAlertDialog.show();
	}

    af_dialog_background圆角:




    

    

    dialog_view:




    

        

        

            
        
    

    

        

    最后是style:


        @null
        true
        true
        true
        @android:color/transparent
        @android:color/transparent
        true
        0.6
    

    谢谢hongyang大神~~开心挣钱每一天