簡體   English   中英

我看不到Linearlayout的背景

[英]I can not see the background of Linearlayout

早上好!

我有一個關於Linearlayout的問題。 我在XML中設置了背景顏色,並且在運行該應用程序時背景發生了變化。

但是,如果我將代碼放在應用程序的按鈕偵聽器中並進行了更改,則沒有更改。出於什么原因?

** LinearLayout XML代碼

<LinearLayout
android:id="@+id/page"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1"
android:background="@color/white"
>

**我的活動代碼

page = (LinearLayout)findViewById(R.id.page);
page.setBackgroundColor(getResources().getColor(R.color.gray2));
page.setBackgroundResource(R.color.yellow);

當我嘗試重新創建scnerio時,它正在工作。 您能顯示您為背景添加的偵聽器代碼嗎

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM