1
这是我的main.xmlAndroid。我如何动态改变整个FrameLayout的颜色,而不是View背景的颜色?
<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>
在FrameLayout里,我有一个包含按钮pressThisButton一个视图V。
当按钮被按下时,我能够改变周围的视图按钮填充背景的颜色 - 而不是整个屏幕的背景 - 使用
private OnClickListener buttonClickListener = new OnClickListener()
{
public void onClick(View v)
{
v.setBackgroundColor(0xffff0000);
是否有办法在FrameLayout中更改视图背景和整个屏幕颜色?
谢谢你的时间。
感谢您的快速回复。在我为我的框架布局分配了一个ID后,您的建议完美奏效。再次感谢您的帮助。 – user527405 2011-01-12 21:40:26