2011-08-22 105 views
0

我正試圖通過this link的回答來實現一個邊框來包裹我的編輯文本。在android中繪製邊框的問題

然而,當我試圖誇大它嘗試它是如何工作的,我得到一個錯誤

android.view.InflateException: Binary XML file line #4: Error inflating class shape 

爲什麼會這樣呢?

編輯

,我將這些XML文件(edittext.xml)

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

<shape 
    android:shape="rectangle"> 
    <solid android:color="#FAFAD2" />   
    <stroke android:width="1sp" android:color="#000000" 
     android:dashWidth="7sp" android:dashGap="5sp" /> 
</shape> 

</FrameLayout> 

public class EditBox extends View { 

    private LayoutInflater layoutInflater; 
    private FrameLayout viewLayout; 

    public EditBox(Context context) { 
     super(context); 

     try { 
      layoutInflater = (LayoutInflater) context.getSystemService (Context.LAYOUT_INFLATER_SERVICE); 
      viewLayout = (FrameLayout) layout_inflater.inflate(R.layout.edittext, null); 

    } catch(Exception e) { 
     e.printStackTrace(); 
    } 
} 

    public View getView() { 
     return viewLayout; 
    } 
} 
+0

告訴我們你的代碼 –

+0

你不」 t膨脹形狀。請顯示你的代碼。 – Cristian

+0

我已經添加了一些代碼的問題。 –

回答

0

形狀應在XML中可繪製文件夾定義

+0

謝謝,我剛剛意識到我是多麼愚蠢。 –