标签:als round listener vat pack line inter over extend
package com.yxcorp.gifshow.homepage.wiget;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import com.yxcorp.gifshow.home.R;
public class SelfDialog extends Dialog {
private Button mPositiveButton;
private Button mNegativeButton;
private String mPositiveStr, mNegativeStr;
private mNegativeOnclickListener mNegativeOnclickListener;
private mPositiveOnclickListener mPositiveOnclickListener;
public void setNegativeOnclickListener(String str, mNegativeOnclickListener mNegativeOnclickListener) {
if (str != null) {
mNegativeStr = str;
}
this.mNegativeOnclickListener = mNegativeOnclickListener;
}
public void setPositiveOnclickListener(String str, mPositiveOnclickListener mPositiveOnclickListener) {
if (str != null) {
mPositiveStr = str;
}
this.mPositiveOnclickListener = mPositiveOnclickListener;
}
public SelfDialog(Context context) {
super(context, R.style.MyDialog);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.custom_dialog);
setCanceledOnTouchOutside(false);
initView();
initEvent();
}
private void initEvent() {
mPositiveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mPositiveOnclickListener != null) {
mPositiveOnclickListener.onPositiveClick();
}
}
});
mNegativeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mNegativeOnclickListener != null) {
mNegativeOnclickListener.onNegativeClick();
}
}
});
}
private void initView() {
mPositiveButton = findViewById(R.id.bt_positive);
mNegativeButton = findViewById(R.id.bt_negative);
}
public interface mPositiveOnclickListener {
public void onPositiveClick();
}
public interface mNegativeOnclickListener {
public void onNegativeClick();
}
}
custom_dialog.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#11ffffff">
<LinearLayout
android:layout_width="260dp"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/free_dialog"
android:orientation="vertical">
<TextView
android:textStyle="bold"
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="15dp"
android:gravity="center"
android:text="快手"
android:textColor="#000000"
android:textSize="16sp" />
<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="70dp"
android:text="确定退出当前用户吗?" />
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_marginTop="30dp"
android:background="#E4E4E4" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal">
<Button
android:id="@+id/bt_negative"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="@null"
android:gravity="center"
android:singleLine="true"
android:text="@string/cancel"
android:textColor="#7D7D7D"
android:textSize="16sp" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="#E4E4E4" />
<Button
android:id="@+id/bt_positive"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:background="@null"
android:gravity="center"
android:singleLine="true"
android:text="@string/ok"
android:textColor="#FF5722"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
free_dialog.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#ffffff" />
<stroke
android:width="0.8dp"
android:color="#ffffff" />
<!-- 圆角 -->
<corners android:radius="6dp" />
</shape>
<!--自定义dialog背景全透明无边框theme -->
<style name="MyDialog" parent="android:style/Theme.Dialog">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
标签:als round listener vat pack line inter over extend
原文地址:https://www.cnblogs.com/liunx1109/p/12262814.html