Title bar color change issues

前端 未结 2 950
感情败类
感情败类 2021-01-24 23:23

I want to change the color of the title bar dynamically, ie: someone clicks a button, it changes the color. However, I can\'t seem to get it to fill the entire title bar. This o

相关标签:
2条回答
  • 2021-01-24 23:45

    try this

    titleBar = (RelativeLayout) findViewById(R.id.title_bar);
    final FrameLayout titleContainer = (FrameLayout)titleBar.getParent(); 
     titleContainer.setPadding(0, 0, 0, 0)
    titleBar.setBackgroundResource(R.color.title_bar_green);
    
    0 讨论(0)
  • 2021-01-24 23:57

    Try this ((View) titleBar.getParent()).setBackgroundColor(R.color.title_bar_green); It is not the best way to do the job. But if it works, then you will know that you need to set background color of R.id.title_bar parent.

    0 讨论(0)
提交回复
热议问题