【发布时间】:2014-09-05 11:49:42
【问题描述】:
我有一个带有 textviews 和 imageviews 的 relativeLayout。
当我像这样覆盖布局时:
color = new ColorDrawable(Color.argb(80, 0, 0, 0));
mMainLayout.setBackground(color);
布局有一些较深的颜色。
除了它们保持相同的图像视图。所以我想我试试看
statsImage.setImageAlpha(255);
但图像仍然保持不变。
有人可以帮助我吗?
还有人解释为什么 imageview 没有得到覆盖?它是布局的子元素:
<ImageView
android:id="@+id/headerImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape_profile_pic" />
<ImageView
android:id="@+id/statsImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="70dp"
android:background="@drawable/shape_stats" />
</RelativeLayout>
编辑:
我现在明白了:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/overlayMainView"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
我这样设置背景颜色:
color = new ColorDrawable(Color.argb(80, 0, 0, 0));
mMainViewOverlay.setBackground(color);
【问题讨论】:
-
mMainLayout.setBackground(color);设置,嗯,背景播种背景如何覆盖前景中的东西?你需要的是一个完全覆盖你的相对布局的视图
-
所以我只需要在所有内容周围添加一个
并设置背景颜色? -
我不能更好地表达它,是的,只需使用普通的 View 并将其背景颜色设置为半透明
-
发现了问题:)。感谢您的帮助。