想看一下网易的效果吧
看起来还不错,那我们现在就模仿一下网易,也实现相同的效果吧
1.创建MyCustomDialog集成Dialog
private Context context;
private TextView tv1;
private TextView tv2;
private TextView tv3;
private TextView tv4;
private TextView tv5;
//
public MyCustomDialog(Context context) {
this(context, R.style.dialog);
this.context = context;
}
//有两个参数的构造函数,themeResId可以定制Dialog的样式
public MyCustomDialog(Context context, int themeResId) {
super(context, themeResId);
View contentView = UIUtils.inflate(R.layout.dialog_accuse_complaint);
tv1 = (TextView) contentView.findViewById(R.id.tv1);
tv2 = (TextView) contentView.findViewById(R.id.tv2);
tv3 = (TextView) contentView.findViewById(R.id.tv3);
tv4 = (TextView) contentView.findViewById(R.id.tv4);
tv5 = (TextView) contentView.findViewById(R.id.tv5);
setListener();
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.setContentView(contentView);
}
/**
* 设置监听
*/
private void setListener() {
tv1.setOnClickListener(this);
tv2.setOnClickListener(this);
tv3.setOnClickListener(this);
tv4.setOnClickListener(this);
tv5.setOnClickListener(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 设置为底部显示
getWindow().setGravity(Gravity.BOTTOM);
WindowManager m = getWindow().getWindowManager();
Display d = m.getDefaultDisplay();
// 设置宽度填充屏幕
WindowManager.LayoutParams p = getWindow().getAttributes();
p.width = d.getWidth();
getWindow().setAttributes(p);
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.tv1:
break;
case R.id.tv2:
break