//布局-----------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout
android:orientation="vertical"
android:background="@drawable/btn_assets_receive"
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="20dp"
android:textColor="#ff252525"
android:text="设置屏蔽范围"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_gravity="center"/>
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<CheckBox
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:button="@mipmap/empty"
android:layout_marginLeft="20dp"
android:id="@+id/checkbox1"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="17dp"
android:layout_marginLeft="8dp"
android:textColor="#ff4a4a4a"
android:text="不看他的视频"/>
</LinearLayout>
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textSize="13dp"
android:textColor="#ff4a4a4a"
android:text="信息流里不再显示他的视频"
android:layout_marginLeft="44dp"/>
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<CheckBox
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginLeft="20dp"
android:button="@mipmap/empty"
android:id="@+id/checkbox2"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="17dp"
android:textColor="#ff4a4a4a"
android:layout_marginLeft="8dp"
android:text="禁止他对我的视频互动"
android:layout_marginTop="7dp"/>
</LinearLayout>
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textSize="13dp"
android:textColor="#ff4a4a4a"
android:text="他无法对我的视频评论,点赞,分享"
android:layout_marginTop="4dp"
android:layout_marginBottom="15dp"
android:layout_marginLeft="44dp"/>
<TextView
android:background="#ccc"
android:layout_height="1dp"
android:layout_width="match_parent"/>
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<Button
android:background="#fff"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="18dp"
android:textColor="#ff252525"
android:text="取消屏蔽"
android:layout_weight="1"/>
<TextView
android:layout_height="10dp"
android:layout_width="1dp"/>
<Button
android:background="#fff"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="18dp"
android:textColor="#ff252525"
android:text="确定屏蔽"
android:layout_weight="1"
android:topRightRadius="13dp"/>
</LinearLayout>
</LinearLayout>
//MainActvity-------------------------------------------------------
package com.qjtc.magicalar.activity;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import com.qjtc.magicalar.R;
public class VideoActivity extends AppCompatActivity {
private ImageView backs;
private ImageView shield;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video);
backs = findViewById(R.id.backs);
shield = findViewById(R.id.shield);
backs.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
//弹出框
shield.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
View inflate = View.inflate(VideoActivity.this, R.layout.shield_dialog, null);
CheckBox checkBox1 = inflate.findViewById(R.id.checkbox1);
CheckBox checkBox2 = inflate.findViewById(R.id.checkbox2);
checkBox1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked){
buttonView.setButtonDrawable(R.mipmap.dui);
}else {
buttonView.setButtonDrawable(R.mipmap.empty);
}
}
});
checkBox2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked){
buttonView.setButtonDrawable(R.mipmap.dui);
}else {
buttonView.setButtonDrawable(R.mipmap.empty);
}
}
});
AlertDialog.Builder builder = new AlertDialog.Builder(VideoActivity.this);
builder.setView(inflate);
builder.create().show();
}
});
}
}
//Drawlayout-------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#ffffff" />
<corners android:radius="4dp" />
</shape>