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 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;
}
}
形状应在可绘制文件夹的xml中定义
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.