Just use the Layout where the container is located as the view, for example:
public class SnackbarTestActivity extends Activity { CoordinatorLayout container; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_snackbar_test); container = (CoordinatorLayout) findViewById(R.id.container); } public void createSnackbar(View v) { Snackbar.make(container, "SnackbarTest", Snackbar.LENGTH_LONG).show(); } }
Just use the Layout where the container is located as the view, for example: