<————–MainActivity ———————>
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private PopupWindow popupWindow;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().hide();
setContentView(R.layout.activity_main);
}
public void aaa(View view) {
// startActivity(new Intent(this,testActivity.class));
View view1 = LayoutInflater.from(this).inflate(R.layout.popuwindow, null);
popupWindow = new PopupWindow(view1, LinearLayoutCompat.LayoutParams.MATCH_PARENT, LinearLayoutCompat.LayoutParams.MATCH_PARENT);
// popupWindow.setContentView(view1);
View rootview = LayoutInflater.from(MainActivity.this).inflate(R.layout.activity_main, null);
popupWindow.showAtLocation(rootview, Gravity.BOTTOM, 0, 0);
view1.setOnClickListener(this);
}
@Override
public void onClick(View v) {
popupWindow.dismiss();
}
}
<—————-popupWindow布局文件———————->