How to programmatically change the background image of an Android Activity

前端 未结 3 996
野性不改
野性不改 2021-02-06 05:24

I have been able to change colour of an activity background (see this post). Now a requirement is to do the same with background image. I mean I can click a button, select an op

3条回答
  •  说谎
    说谎 (楼主)
    2021-02-06 06:01

    add this to your activity.xml:

    
    

    add this to activity.java:

    ImageView layout = (ImageView) findViewById(R.id.background);
                layout.setBackgroundResource(R.drawable.iso);
    

提交回复
热议问题