如果有可能你能告诉我怎么办?另外,请告诉我什么可以用来代替Snackbar?
答案 0 :(得分:1)
你可以这样做
CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.main_content);//coordimator layout where you use snackbar
snackbar = Snackbar.make(coordinatorLayout, "", Snackbar.LENGTH_INDEFINITE);
Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout) snackbar.getView();//get the snackbar's view
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View snackView = inflater.inflate(R.layout.custom_layout, null);
snackView.setBackgroundColor(Color.WHITE);
layout.addView(snackView, 0);//add our custom view to snackbar
snackbar.show();