0

如何在矩形框中制作透明的黑色。(颜色为黑色,但需要透明,需要显示后面的屏幕)

我在下面设计了链接,但它是全黑的。我更改了颜色代码,但它不是黑色透明的。

我作为下拉列表添加的图像是黑色的

在此处输入图像描述

如果我添加任何其他透明颜色,它显示如下。矩形区域变厚

在此处输入图像描述

我怎样才能使整体像下面一样透明黑色。我也需要整个黑色变成下面的颜色

在此处输入图像描述

我的代码:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:right="10dp" android:top="10dp">
        <shape
            android:shape="rectangle">
            <solid android:color="#000000"/>
            <corners
                android:bottomLeftRadius="15dp"
                android:bottomRightRadius="35dp"
                android:topLeftRadius="15dp"
                android:topRightRadius="10dp" />
        </shape>
    </item>
    <item android:right="1dp" android:bottom="10dp" android:bottomRightRadius="100dp">
        <rotate
            android:fromDegrees="-30"
            android:pivotX="100%"
            android:pivotY="0%"
            >
            <shape android:shape="rectangle">
                <solid android:color="@color/black"  />
            </shape>
        </rotate>

    </item>

</layer-list>
4

3 回答 3

1

将 alpha 添加到视图中。无需编辑形状。

<View
        android:alpha="0.5"
        android:id="@+id/view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/shape"/>

如果您运行应用程序,这将有效。设计编辑器显示的与应用程序显示的不同,因此您需要对其进行测试!

于 2020-12-10T12:46:12.637 回答
-1
android:background="#CC000000"

在 XML 中

其中CC是alpha值,00是红色因子,00是绿色因子,00是蓝色因子。

一些不透明代码:

100% — FF
95% — F2
90% — E6
85% — D9
80% — CC
75% — BF
70% — B3
65% — A6
60% — 99
55% — 8C
50% — 80
45% — 73
40% — 66
35% — 59
30% — 4D
25% — 40
20% — 33
15% — 26
10% — 1A
5%  — 0D
0% —  00
于 2020-12-10T06:54:25.987 回答
-1

尝试这个:

ic_chat_bubble_24.xml:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:alpha="0.28"// customize on your own
    android:autoMirrored="true"
    android:tint="?attr/colorControlNormal"
    android:viewportWidth="24"
    android:viewportHeight="24">
    <path
        android:fillColor="@android:color/white"
        android:pathData="M20,2H4c-1.1,0 -2,0.9 -2,2v18l4,-4h14c1.1,0 2,-0.9 2,-2V4c0,-1.1 -0.9,-2 -2,-2z" />
</vector>

并将其旋转 180 度

ic_chat.xml

<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/ic_baseline_chat_bubble_24"
    android:fromDegrees="180">

</rotate>

输出

于 2020-12-10T07:06:15.140 回答