我有一个父布局内的子布局。如果我为父项设置了任何背景颜色,它也会为其子项设置相同的颜色。但我不想为孩子设置相同的颜色。 (我想默认的Android黑色作为背景为孩子)。请帮帮我。
编辑:
我需要捕获子布局和稍后创建一个位图,所以我不应该为子设置任何背景色(但其父应该有一些颜色)。它应该设置为默认的Android黑色。如何为子布局设置默认的Android黑色,而其父母有另一种背景颜色?
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#FFA500" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_margin="15dp"
android:layout_weight="1"
android:gravity="center" >
</RelativeLayout>
</LinearLayout>
父线性布局有一些BG颜色。我没有为孩子的相对布局设置任何BG颜色,但它取得父母的BG颜色。那么现在,我如何设置android默认的BG颜色为孩子?
孩子是一个视图。所以通过使用yourParentView.findViewByid(R.id.yourChildId);并设置它的背景颜色 –
我编辑了我的问题。我不希望任何背景的孩子布局,而其父母有一些颜色。 – SANDHYA
我不明白你想要做什么 –