英文:
Is it matter if setting View alpha with alpha attribute or adding suitable value to background attribute?
问题
由于某种我无法理解的原因,当我想要将某个视图的不透明度设置为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"/>
以及以下代码:
<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:alpha="0.6"/>
我得到了不同的颜色,虽然在十六进制背景的开头是99,但在0.6倍数中等于255。有人可以解释一下为什么在这两段代码中我得到了不同的颜色吗?
英文:
For some reason i can't understand when i want to set opacity of 0.6 to some view, so when i set the following code:
<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"/>
and the following code:
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"/>
i get a different colour , ** althugh** 99 in the beginning of the background in hexa is equal to 255 multiple in 0.6
can someone explain me why i get different colours in both codes?
专注分享java语言的经验与见解,让所有开发者获益!
评论