gpt4 book ai didi

android - 仅将 alpha-transparency 设置为布局而不是其子级

转载 作者:IT老高 更新时间:2023-10-28 23:10:55 26 4
gpt4 key购买 nike

我发现了这个问题,我也遇到了几乎同样的问题。我如何将 alpha 仅应用于相对布局而不应用于其子布局?有人可以帮忙吗?

I have a rectangular LinearLayout that has some margin, some round corners and an alpha value of 0.3. Inside this layout I have 4 different layouts as I display different images in different positions. My issue is that although the primary layout is 0.3, I want my child to be fully visible, or not affected by it's parent alpha, and I am wondering how I can please do that please? I have tried setting alpha=1 on the children layouts but it did not work. Setting it to 0 does make the children layout disappear though, so it seems I can reduce below 0.3 but not anything above the parent. Is that a bug or am I doing it wrong please? Thank you.

最佳答案

您可以使用 FrameLayout 代替设置父级的 alpha 并首先设置背景图像并设置该子级的 alpha。例如

而不是使用这个

<LinearLayout 
android:background="@drawable/background"
android:alpha="0.3" >
<LinearLayout>
<Button />
<Button />
</LinearLayout>
</LinearLayout >

用这个

<FrameLayout>
<ImageView
android:background="@drawable/background"
android:alpha="0.3" />
<LinearLayout>
<Button />
<Button />
</LinearLayout>
</FrameLayout>

关于android - 仅将 alpha-transparency 设置为布局而不是其子级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15392897/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com