【问题标题】:android vector background color transparentandroid 矢量背景颜色透明
【发布时间】:2017-04-01 16:32:54
【问题描述】:

我的主要布局是这样的。

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/transparent"
    android:orientation="vertical"
    android:padding="0dp"
    tools:context="com.send.apk.bluetoothappsend.MainActivity">

    <include
        android:id="@+id/tool_bar"
        layout="@layout/tool_bar" />

    <android.support.v7.widget.RecyclerView
        android:id="@+id/rv"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="@drawable/background" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="@dimen/_80sdp"
        android:background="@drawable/ic_footer" />
</LinearLayout>

我使用以下向量

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="1124dp"
        android:height="306dp"
         android:tint="@android:color/transparent"
        android:viewportWidth="11240.0"
        android:viewportHeight="3060.0">
    <path
        android:pathData="M179,3046c-111,-20 -146,-55 -166,-170 -17,-96 -18,-1749 -2,-1861 18,-122 69,-172 194,-194 41,-7 417,-11 1126,-11 585,0 1168,-5 1294,-10 330,-14 760,-47 905,-70 415,-63 789,-207 1132,-437 277,-184 448,-251 718,-278 183,-19 297,-19 480,0 270,27 441,94 718,279 370,247 789,400 1238,451 462,52 862,65 2088,65 713,0 1090,4 1131,11 125,22 176,72 194,194 16,112 15,1765 -2,1861 -21,117 -54,150 -171,171 -100,17 -10778,17 -10877,-1z"
        android:strokeColor="#00000000"
        android:fillColor="#090b17"/>
</vector>

但问题是,图片中存在一些黑色背景,我需要透明背景

【问题讨论】:

  • 您可以在包含您的 RelativeLayout 的视图中使用深色背景吗?
  • 不是,如果你愿意,我会附上所有的布局
  • 那么,您的应用中是否使用了深色主题?
  • 可能是,这个怎么解决?
  • 检查AndroidManifest.xml中的android:theme属性

标签: android android-layout android-xml android-vectordrawable


【解决方案1】:

首先,如果您需要一个透明的视图,您可能甚至不应该首先使用矢量图像。但问题是您将填充颜色设置为#090b17,应该是#00000000

或者,您可以将RelativeLayout 的背景设置为:

android:background="@android:color/transparent" 

【讨论】:

    【解决方案2】:

    这样试试

    <?xml version="1.0" encoding="UTF-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/transparent"
        android:orientation="vertical"
        android:padding="0dp"
        tools:context="com.send.apk.bluetoothappsend.MainActivity">
    
        <include
            android:id="@+id/tool_bar"
            layout="@layout/tool_bar" />
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/background"
            android:orientation="vertical">
    
            <android.support.v7.widget.RecyclerView
                android:id="@+id/rv"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1" />
    
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="@dimen/_80sdp"
                android:background="@drawable/ic_footer" />
        </LinearLayout>
    
    
    </LinearLayout>
    

    【讨论】:

      猜你喜欢
      • 2012-11-05
      • 2012-06-26
      • 1970-01-01
      • 2014-03-22
      • 2019-09-29
      • 1970-01-01
      • 2021-07-02
      • 2013-09-02
      • 2011-04-14
      相关资源
      最近更新 更多