2011-01-12 5 views
1

これは私のmain.xmlでframeLayoutでAndroid。 ViewBackroundの色だけでなく、FrameLayout全体の色を動的に変更するにはどうすればよいですか?

<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> 

ですが、私はボタンpressThisButtonが含まれているビューVを持っています。

ボタンが押されたとき、私はビュー内のボタンの周囲のパディング、背景の色を変更することができています - ではなく、画面全体の背景 -

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


     { 


      v.setBackgroundColor(0xffff0000); 

を使用しては、方法はありますFrameLayoutでビューの背景と画面全体の色を変更しますか?

ありがとうございます。

答えて

2

findViewByIdを使用してFrameLayoutを取得し、背景色を設定できます。

+0

ご連絡ありがとうございます。フレームレイアウトにIDを割り当てたら、あなたの提案は完全に機能しました。もう一度あなたの助けをしてくれてありがとう。 – user527405

関連する問題