<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/off_background">
<ImageView
android:id="@+id/bottom_layer"
android:src="@drawable/handle"/>
<ImageView
android:id="@+id/upper_layer"
android:src="@drawable/switch_v"/>
</FrameLayout>
无论何时执行该代码:二进制XML文件行#7:您必须提供layout_width属性
inflater.inflate(R.layout.settings_switch, this);
我得到这个错误:
10-29 13:27:00.090: E/AndroidRuntime(22364): Caused by: java.lang.RuntimeException: Binary XML file line #7: You must supply a layout_width attribute.
怎么会这样?
我有
android:layout_width="match_parent"
android:layout_height="match_parent"
你会发现这个错误的另一种情况是:尺寸在dimens.xml为sw720dp定义,但它不是对设备的定义比sw720dp低,你用这个扪VAR设置layout_width,它会坠毁在更小的设备比sw720dp –