效果
android:layout_height="100dp"
android:background="@drawable/shape_corner"
android:gravity="center"
android:orientation="vertical">
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="是否退出"
android:layout_marginTop="10dp"/>
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="10dp"
android:background="#c6c1c1" />
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center">
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="取消" />
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="确定" />
drawable/shape_corner.xml
MainActivity
public class MainActivity extends AppCompatActivity {
private Context mContext;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mContext = this;
findViewById(R.id.open_btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//弹出自定义dialog
CustomDialog dialog = new CustomDialog(mContext,R.layout.custom_dialog);
dialog.show();
}
});
}
}