Style SnackBar in theme app

前端 未结 5 1668
深忆病人
深忆病人 2020-12-01 16:10

I need help. How can I change the design of the text in snackbar in styles app? The change in the code does not interest me. I found the following code. But it is not worki

5条回答
  •  我在风中等你
    2020-12-01 16:20

    Refer to this link for more information:

    // create instance

    Snackbar snackbar = Snackbar.make(view, text, duration);
    

    // set action button color

    snackbar.setActionTextColor(getResources().getColor(R.color.indigo));
    

    // get snackbar view

    View snackbarView = snackbar.getView();
    

    // change snackbar text color

    int snackbarTextId = android.support.design.R.id.snackbar_text;
    TextView textView = (TextView)snackbarView.findViewById(snackbarTextId);
    textView.setTextColor(getResources().getColor(R.color.indigo));
    

    // change snackbar background

    snackbarView.setBackgroundColor(Color.MAGENTA);
    

提交回复
热议问题