首页 > 代码库 > 自定义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"?> <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>
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。