自己定义Android Dialog

著论准过秦,作赋拟子虚。这篇文章主要讲述自己定义Android Dialog相关的知识,希望能为你提供帮助。

private void showDialog() { mDialog = new Dialog(this); mDialog.setCanceledOnTouchOutside(true); Window dialogWindow = mDialog.getWindow(); dialogWindow.setBackgroundDrawable(new ColorDrawable(0)); dialogWindow.setContentView(R.layout.set_public_client_dialog); mDialog.show(); Button cancelbtn = (Button) dialogWindow.findViewById(R.id.cancelbtn); cancelbtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mDialog.dismiss(); } }); Button confirmbtn = (Button) dialogWindow.findViewById(R.id.confirmbtn); confirmbtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mDialog.dismiss(); } }); }




< ?xml version="1.0" encoding="utf-8"?
【自己定义Android Dialog】> < RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="306dp" android:layout_height="262dp" android:layout_gravity="center" android:background="@drawable/followupdialog_306_202" > < FrameLayout android:layout_width="140dp" android:layout_height="32dp" android:layout_marginLeft="-4dp" android:layout_marginTop="7dp" android:background="@drawable/redrobin_89_32" > < TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="top" android:layout_marginLeft="13dp" android:layout_marginTop="4dp" android:text="@string/set_public_reason" android:textColor="@color/white" android:textSize="15sp" /> < /FrameLayout> < EditText android:id="@+id/et_additional_reason" android:layout_width="257dp" android:layout_height="33dp" android:layout_above="@+id/bottom_btns" android:layout_centerHorizontal="true" android:layout_marginBottom="3dp" android:background="@drawable/redline_257_33" android:hint="@string/et_additional_reason_hint" android:paddingLeft="5dp" android:singleLine="true" android:textSize="14sp" /> < LinearLayout android:id="@+id/bottom_btns" android:layout_width="299dp" android:layout_height="44dp" android:layout_alignParentBottom="true" android:layout_marginBottom="6dp" android:layout_marginLeft="7dp" android:layout_marginRight="1dp" android:orientation="horizontal" > < Button android:id="@+id/cancelbtn" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:background="@drawable/followupdialogbtn" android:text="@string/cancel" android:textColor="@color/black" /> < ImageView android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="0.01" android:background="@color/linecolor" /> < Button android:id="@+id/confirmbtn" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:background="@drawable/followupdialogbtn" android:text="@string/confirm" android:textColor="@color/black" /> < /LinearLayout> < ImageView android:layout_width="299dp" android:layout_height="0.5dp" android:layout_above="@id/bottom_btns" android:layout_marginLeft="7dp" android:background="@color/linecolor" /> < /RelativeLayout>



    推荐阅读