开发者

Android. How do I dynamically change the color of the entire FrameLayout instead of just the color of the View backround?

This is my main.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#FFFFFF"
    >

<ImageButton android:background="@null"  android:layout_gravity="center_vertical|center_horizontal|center" 
android:layout_width="wrap_content" android:layout_height="wrap_content"  android:src="@drawable/sample" android:id="@+id/pressThisButton" android:layout_y="40px" android:layout_x="20px"></ImageButton>
</FrameLayout>

In the Framelayout, I have a View v which contains the button pressThisButton.

When the button is 开发者_JAVA技巧pressed I am able to change the color of the padding background surrounding the button in the view--but not the background of the entire screen--using

private OnClickListener buttonClickListener = new OnClickListener() 
    {
        public void onClick( View v )


        {


            v.setBackgroundColor(0xffff0000);

Is there a way in a FrameLayout to change both the view background and the entire screen color?

Thank you for your time.


You could get the FrameLayout using findViewById and set the background color on it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜