【发布时间】:2013-10-29 11:40:58
【问题描述】:
<?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>
无论何时执行此代码:
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的设备没有定义,你使用这个dimen var来设置layout_width,并且它会在小于 sw720dp 的设备上崩溃