Android: Making changes to a button's parent view

后端 未结 1 1366
予麋鹿
予麋鹿 2021-02-18 19:41

I have a RelativeLayout with a button inside it. Once the user clicks on that button, I would like to change the background of the parent view (RelativeLayout). I know I can do

相关标签:
1条回答
  • 2021-02-18 20:01

    Try View.getParent():

    Button yourBtn = (Button) findViewById(R.id.your_btn);
    RelativeLayout yourRelLay = (RelativeLayout) yourBtn.getParent();
    
    0 讨论(0)
提交回复
热议问题