2017-02-24 149 views

回答

1

您需要指定其背景將被更改的佈局。我猜你有一個的LinearLayout,所以加一個id佈局(如果不存在的話):

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:[email protected]+id/parentLayout> 

然後你就可以改變Java中的背景:

LinearLayout linearLayout = (LinearLayout) findViewById(R.id.parentLayout); 
linearLayout.setBackgroundResource(R.drawable.new_background); 

希望它可以幫助你!

相關問題