[英]Strange Black border around drawable android XML
I am drawing custom header to input information in my app. 我正在绘制自定义标题以在我的应用程序中输入信息。 I have drawn 2 shapes in xml and then positioned them in a layout.
我在xml中绘制了2个形状,然后将它们放置在布局中。 That layout is then put in my main layout using .
然后将该布局放入我的主布局中。 However there is a black border that is drawn around each of the included headers.
但是,每个包含的标题周围都有一个黑色边框。 This seems to only be on api 21 devices.
这似乎只适用于api 21设备。 What is going on?
到底是怎么回事?
circle.xml 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 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>
Header layout 标题布局
<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>
Included layout 包含的布局
<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"/> ...
尝试在你的line.xml中添加这个<solid android:color="#00FFFFFF"/>
。
Remove this: 删除这个:
<stroke android:width="5dp"
android:color="@color/color_primary"/>
From line.xml
来自
line.xml
This is adding the extra "border", using the color_primary
color resource as defined in your colors.xml. 这是使用
color_primary
中定义的color_primary
颜色资源添加额外的“边框”。
Figured it out! 弄清楚了! Using same basis as @Der Golem I removed the
使用与@Der Golem相同的基础我删除了
<size android:height="10dp" />
from the line.xml. 来自line.xml。 Since the stroke was half of the size I was receiving the border.
由于中风是我接收边界的一半。 Thanks for the help all!
谢谢大家的帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.