【问题标题】:How to make a transparent black color in a rectangular box. (color is black, but it needs to be transparent and need to show the screen behind)如何在矩形框中制作透明的黑色。 (颜色为黑色,但需要透明,需要显示后面的屏幕)
【发布时间】:2021-03-21 14:11:54
【问题描述】:

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

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

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

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

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

我的代码:

<?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>

【问题讨论】:

  • 您可以通过单击左侧的灰色大复选按钮来接受一个答案(如果它对您有帮助)。

标签: java android android-studio android-layout android-palette


【解决方案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"/>

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

【讨论】:

    【解决方案2】:

    试试这个:

    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>
    

    【讨论】:

    • 你能告诉我如何根据弹出窗口中的项目列表增加chat_bubble的宽度和高度。我有多个文本的弹出窗口
    • ic_chat.xml 设置为视图的背景(TextView,LinearLayout),以便根据视图的高度和宽度进行操作
    【解决方案3】:
    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
    

    【讨论】:

    • 但是在对这两种颜色应用时,矩形颜色会变成深黑色。它看起来像这样i.stack.imgur.com/92u8K.png
    • 去除第二个形状纯色
    • 如果我删除它,它不会显示箭头
    猜你喜欢
    • 1970-01-01
    • 2013-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多