2015-01-23 6 views
1

9월 1일부터 23일까지 : 07 : 52.570 : E는/AndroidRuntime (2007) : android.view.InflateException : 바이너리 XML 파일 라인 # 50 :이 오류가 발생했습니다 오류 클래스 모양오류 팽창 클래스 모양

을 팽창 구현하면서 내 xml 파일의 셰이프 (타원형) ..이 문제는 무엇입니까? 내가 뭐 놓친 거 없니?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:map="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" 
    android:padding="10dp" > 

    <TextView 
     android:id="@+id/recName" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true"  
     /> 



     <shape android:shape="oval"> 
     <solid android:color="#9F2200"/> 
     <stroke android:width="2dp" android:color="#fff" /> 
     <size android:width="80dp" android:height="80dp"/> </shape> 


</RelativeLayout> 
+1

안녕, 내 솔루션이 밖으로 일입니다 customdrawable.xml 이름으로이 파일을 저장을? 그것이 전체 수용을 사용한다면, +1 –

답변

2

모양은 Drawable 아닌 View입니다.

별도의 드로어 블 XML 파일을 만들면됩니다. 레이아웃에서 ImageView을 사용하고 배경을 사용자가 만든 드로어 블 파일로 설정하십시오.

4

1) 레이아웃 파일에 모양을 만들면 안됩니다.

2) 드로어 블 폴더의 일부로 셰이프 파일을 만들어야합니다.

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:map="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" 
    android:padding="10dp" > 
    <TextView 
     android:id="@+id/recName" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:background="@drawable/customdrawable" 
     /> 
</RelativeLayout> 

오른쪽 그리기 폴더를 클릭하고 당김 폴더에 새 안드로이드 XML을 생성합니다

<shape android:shape="oval"> 
     <solid android:color="#9F2200"/> 
     <stroke android:width="2dp" android:color="#fff" /> 
     <size android:width="80dp" android:height="80dp"/> </shape> 

+0

똑똑한 대답 그레이트! –