Java Andorid快餐栏显示封面视图

时间:2019-04-03 10:18:49

标签: java android android-snackbar

在我看来,我有一个Google地图,当我单击标记时我想显示一个快餐栏,现在我显示一个快餐栏,但是这个快餐栏覆盖了我的Google地图

这就是我所做的:

public void mySnackbar(PGO pgo,View view) {
    LinearLayout.LayoutParams objLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    Snackbar snackbar = Snackbar.make(view, "", Snackbar.LENGTH_INDEFINITE);
    Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout) snackbar.getView();
    layout.setPadding(0, 0, 0, 0);
    LayoutInflater mInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    View snackView = getLayoutInflater().inflate(R.layout.my_snackbar, null);
    Button textViewOne = (Button) snackView.findViewById(R.id.txtOne);
    TextView tvName = (TextView) snackView.findViewById(R.id.name);
    tvName.setText(pgo.getFull());
    textViewOne.setText("Potwierdź");
    textViewOne.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.i("One", "First one is clicked");
            snackbar.dismiss();
        }
    });

    Button textViewTwo = (Button) snackView.findViewById(R.id.txtTwo);
    textViewTwo.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.i("Two", "Second one is clicked");
            snackbar.dismiss();

        }
    });


      gMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
            @Override
            public boolean onMarkerClick(Marker marker) {
                for(PGO pgo : pgoList.pgos){
                    if(pgo.getFull().equalsIgnoreCase(marker.getTitle())){
                        currentPGO = pgo;
                        View view = findViewById(R.id.map);
//                        mySnackbar(pgo,getWindow().getDecorView());
                        mySnackbar(pgo,view);
                    }
                }
                return false;
            }
        });

我想显示一个SnackBar并窃取显示整个Google Maps,我想在Google Maps下耗散Snackbar

enter image description here

0 个答案:

没有答案