首页 > 解决方案 > 使用 alpha 属性设置 View alpha 或为背景属性添加合适的值是否重要?

问题描述

出于某种原因,我无法理解何时要将不透明度设置为 0.6 到某个视图,所以当我设置以下代码时:

<View
    android:id="@+id/bottom_divider"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"
    android:background="#9903a9f4"/>

和以下代码:

 android:id="@+id/bottom_divider"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"
    android:background="#9903a9f4"
    android:alpha="0.6"/>

我得到了不同的颜色,** althugh** 99在六进制背景的开头等于 255 倍数在 0.6 有人可以解释我为什么我在两个代码中得到不同的颜色吗?

标签: javaandroidandroid-layoutalpha

解决方案


推荐阅读