android - 可绘制的android XML周围出现奇怪的黑色边框

标签 android xml android-layout android-drawable xml-drawable

我正在绘制自定义标题以在我的应用中输入信息。我在 xml 中绘制了 2 个形状,然后将它们放置在布局中。然后将该布局放入我的主布局中,使用 .但是,每个包含的标题周围都有一个黑色边框。这似乎只适用于 api 21 设备。这是怎么回事?

circle.xml

<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/icon_background"
    android:shape="oval">
    <padding
        android:left="2dp"
        android:top="2dp"
        android:right="2dp"
        android:bottom="2dp" />
    <solid
        android:color="@color/color_primary"
        android:angle="270">
    </solid>
</shape>

line.xml

<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line">
    <stroke android:width="5dp"
        android:color="@color/color_primary"/>

    <size android:height="10dp" />
</shape>

页眉布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:layout_height="5dp"
        android:layout_width="match_parent"
        android:layout_alignParentStart="true"
        android:layout_marginTop="14dp"
        android:src="@drawable/line">
    </ImageView>

    <ImageView
        android:id="@+id/circle"
        android:layout_height="32dp"
        android:layout_width="32dp"
        android:src="@drawable/circle"
        android:layout_centerHorizontal="true">
    </ImageView>

    <ImageView
        android:id="@+id/header_icon"
        android:layout_height="32dp"
        android:layout_width="32dp"
        android:src="@drawable/ic_action_car"
        android:layout_centerHorizontal="true">
    </ImageView>

</RelativeLayout>

包含布局

<RelativeLayout

        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingLeft="@dimen/header_horizontal_margin"
        android:paddingRight="@dimen/header_horizontal_margin"
        android:paddingTop="@dimen/header_vertical_margin"
        android:paddingBottom="@dimen/header_vertical_margin">

        <include
            android:id="@+id/carSpecs"
            layout="@layout/header"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
        </include>

        <Spinner
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="@dimen/header_vertical_margin"
            android:paddingBottom="@dimen/header_vertical_margin"
            android:layout_gravity="center_horizontal"
            android:id="@+id/vehicleSpinner"
            android:layout_below="@+id/carSpecs"/> ...

Screenshot!

最佳答案

尝试添加这个<solid android:color="#00FFFFFF"/>在你的 line.xml 中。

关于android - 可绘制的android XML周围出现奇怪的黑色边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28031236/

相关文章:

xml - 提取存储在 postgresql 表中的 XML 文件

java - 使用 Intent 过滤器从 XML 获取数据的问题

android - 底部导航 View : Change the default highlighted Tab when the app launches

android - 调整大小后,TextView 无法正确换行文本

android - 如何检查 Intent 中是否存在 Extras

android - Cordova 错误在 cmd 命令 : cordova Build android

Java XML 模式验证 elementFormDefault ="qualified"

android - 在同一设备上运行的单独版本?

android - Android 浏览器中列表项后的行

java - 如何维护不同屏幕尺寸的不同值文件夹的大小