有没有办法将 alpha 属性设置为子视图以及父视图?

mi5浦那

我正在开发应用程序,其中我已将自定义可绘制对象设置为具有 alpha 属性的主布局。但它将 alpha 设置为整体视图。我想将 alpha 设置为唯一的主要布局。这样文本将正常显示而没有alpha效果。当前输出

Alpha 效果是由整体视图拍摄的。

<android.support.constraint.ConstraintLayout
        android:id="@+id/containerLinear"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/gradient_with_bottom_curve"
        android:orientation="horizontal"
        android:alpha="0.4"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent">
        <ScrollView
            android:id="@+id/mainScroll"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <LinearLayout
                android:id="@+id/scrollLinear"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">
                <RelativeLayout
                    android:id="@+id/mainRelative"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">
                    <TextView
                        android:id="@+id/txtHeading"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="Business Name"
                        android:gravity="center"
                        android:layout_marginTop="10dp"
                        android:padding="5dp"
                        android:textStyle="bold"
                        android:textSize="20sp"
                        android:textColor="@color/logo_orange"/>
                    <RelativeLayout
                        android:id="@+id/paraOneRelative"
                        android:layout_below="@+id/txtHeading"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">
                        <TextView
                            android:id="@+id/txtParaOneBold"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Some write up"
                            android:gravity="start"
                            android:layout_marginTop="10dp"
                            android:padding="5dp"
                            android:textStyle="normal"
                            android:textSize="12sp"
                            android:textColor="@color/black"/>
                    </RelativeLayout>
                </RelativeLayout>
            </LinearLayout>
        </ScrollView>
    </android.support.constraint.ConstraintLayout>
克里斯文·杰姆

您可以将其FrameLayout用作基础,而不是将ConstraintLayoutScrollView叠加在 a View(具有半透明背景)的顶部应该按照以下方式工作,

<FrameLayout
    android:id="@+id/containerLinear"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <View
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:alpha="0.4"
        android:background="@drawable/gradient_with_bottom_curve" />

    <ScrollView
        android:id="@+id/mainScroll"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <LinearLayout
            android:id="@+id/scrollLinear"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <RelativeLayout
                android:id="@+id/mainRelative"
                android:layout_width="match_parent"
                android:layout_height="match_parent">
                <TextView
                    android:id="@+id/txtHeading"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Business Name"
                    android:gravity="center"
                    android:layout_marginTop="10dp"
                    android:padding="5dp"
                    android:textStyle="bold"
                    android:textSize="20sp"
                    android:textColor="@color/logo_orange"/>
                <RelativeLayout
                    android:id="@+id/paraOneRelative"
                    android:layout_below="@+id/txtHeading"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
                    <TextView
                        android:id="@+id/txtParaOneBold"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Some write up"
                        android:gravity="start"
                        android:layout_marginTop="10dp"
                        android:padding="5dp"
                        android:textStyle="normal"
                        android:textSize="12sp"
                        android:textColor="@color/black"/>
                </RelativeLayout>
            </RelativeLayout>
        </LinearLayout>
    </ScrollView>
</FrameLayout>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

有没有办法在海洋点图中设置透明度/ alpha级别?

有没有办法将python对象保存到磁盘,没有“写”属性

有没有办法将mongodb设置为带有vagrantfile的服务器?

有没有办法在父 ScrollViewReader 的子视图中使用 scrollTo

有没有办法表示休眠的数据视图?

有没有办法让单个视图不旋转?

有没有办法截图背景视图?

有没有办法按日期显示视图?

有没有办法将圆角添加到android材质视图底部导航?

有没有办法以编程方式将滚动视图滚动到特定的编辑文本?

有没有办法将按钮放在 SwiftUI 单元格视图中?

有没有办法将视图函数转换为芹菜任务?

有没有办法将 GraphQL 查询字段分组为子/嵌套查询组?

有没有办法将BackgroundColorSpan设置为SpannableString的动画?

有没有办法将SQL参数的默认值设置为null?

有没有办法将kptr_restrict设置为0?

有没有办法将范围输入的默认值设置为空?

有没有办法将复选框的初始值设置为false?

有没有办法将NaN的元素设置为0?

有没有办法将iOS应用设置为每晚自动下载数据?

有没有办法将sublimetext中的折叠符号设置为只读?

有没有办法将这种类型的字典设置为redis?

有没有办法将场景的内容设置为变量?

有没有办法将stdout设置为二进制模式?

有没有办法将 SendEmailAsync 设置为 isHtml= true?

有没有办法将文件中的列表设置为字典中的值

有没有办法从 Firestore 将资源设置为 XML 文件?

有没有办法将光标设置为 Konvajs 变压器锚

有没有办法将属性标记为有条件