2011-08-22 50 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

谢谢,我刚刚意识到我是多么愚蠢。 –