Change Toolbar background color programmatically does not change Toolbar Title Background color

前端 未结 5 2164
南笙
南笙 2020-12-18 18:11

I´m trying to change the toolbar Background color programmatically by doing this:

getSupportActionBar().setBackgroundDrawable(newColorDrawable(getResources()         


        
5条回答
  •  眼角桃花
    2020-12-18 18:58

    use this to access the textview

    public void changeToggleTitle() {
        if (mToolbar != null) {
            for(int i= 0; i < mToolbar.getChildCount(); i++){
                View v = mToolbar.getChildAt(i);
                if(v != null && v instanceof TextView){
                    TextView t = (TextView) v;
                    // Do the magic 
                }
            }
        }
    }
    

提交回复
热议问题