2015-01-19 4 views
4

내 응용 프로그램의 정보를 입력하기 위해 사용자 정의 헤더를 그리는 중입니다. 나는 xml에 2 개의 도형을 그린 다음 레이아웃에 배치했습니다. 그 레이아웃은 다음을 사용하여 내 메인 레이아웃에 배치됩니다. 그러나 포함 된 각 머리글 주위에 검은 색 테두리가 그려져 있습니다. 이것은 api 21 장치에만있는 것으로 보입니다. 무슨 일 이니?Drawable android 주위의 이상한 검은 색 테두리 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

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

+0

모든 기기에서 발생합니까? Android 에뮬레이터에서 테스트 해 보셨습니까? – alanv

+0

나는 api21 장치에서 그것을 알아 차린다. 낮은 API는 괜찮아 보입니다. – kd8bny

+0

샘플 XML이 제공된 5.0.1 에뮬레이터 또는 Nexus 기기에서이를 재현 할 수 없습니다. 그래도 drawable이 wrap_content 나 10dp로 바뀌는 ImageView의 높이를 바꿀 필요가있었습니다. – alanv

답변

1

알아 냈어! @Der Golem과 같은 기초를 사용하여 나는을 제거했다.

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

line.xml에서. 뇌졸중이 크기의 절반 이었기 때문에 나는 국경을 받고있었습니다. 모두에게 도움을 주셔서 감사합니다!

1

시도는 line.xml이 <solid android:color="#00FFFFFF"/>을 추가 할 수 있습니다.

+0

아니, 아직 국경이 있습니다. Ive가 알아 차 렸던 것은 헤더를 두 번 이상 포함 할 때 테두리가 표시된다는 것입니다. 감사! – kd8bny

1

제거하기 :

<stroke android:width="5dp" 
    android:color="@color/color_primary"/> 

이것은 당신의 colors.xml에 정의 된대로 color_primary 색상 자원을 사용하여 별도의 "경계"를 추가하고

line.xml에서.