2012-02-25 813 views

回答

1

LinearLayoutViewGroup,它又是View

您可以使用View的方法getBackground(),它會給你一個Drawable。現在,如果你設置的LinearLayout的背景是一個顏色,你可以施放該DrawableColorDrawable,然後使用方法getColor()

+0

非常感謝,這是我的代碼:LinearLayout中mScreen =(LinearLayout中)findViewById(R。 id.myScreen); ColorDrawable cD =(ColorDrawable)mScreen.getBackground();但cD不是方法getColor();對不起,但我非常noob – Jjreina 2012-02-25 19:57:22

+0

嗯看來,該方法是可用的API級別11和以上只。看看這篇文章:http://groups.google.com/group/android-developers/browse_thread/thread/4910bae94510ef77?pli=1 – 2012-02-25 20:07:54

+0

謝謝我使用API​​級別10。 – Jjreina 2012-02-25 20:12:05