Problems with drawing a border in android
I am trying to achieve a border to wrap my edittext like this given in the answer of this link.
However, when I tried inflating it to try out how it works, I get an error
android.view.InflateException: Binary XML file line #4: Error inflating class shape
Why is this so?
EDIT
I pasted this in an XML file (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 EditB开发者_Python百科ox(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;
}
}
the shape should define in xml in drawable folder
精彩评论