【发布时间】:2014-07-24 10:41:14
【问题描述】:
我想设计一个布局,但我无法理解在设备中运行时出现错误。
我在使用时遇到了错误
android:layout_above="@+id/frBottom"
线。我在eclipse中设计了布局,好像里面没有问题。
这是我的 xml 文件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<FrameLayout
android:id="@+id/frMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/frBottom"
android:layout_alignParentTop="true" >
<WebView
android:id="@+id/wvMain"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
<FrameLayout
android:id="@+id/frBottom"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:background="#000033" >
</FrameLayout>
</RelativeLayout>
【问题讨论】:
-
去掉
android:id="@+id/frBottom"的加号 -
因为
@+id/..用于为视图分配新 id 而@id/..用于引用另一个视图。 -
@blackbelt 你的意思是来自
android:layout_above="@+id/frBottom"? -
@blackbelt 为什么?
@+id不是用来给View添加ID,@id不是用来引用一个吗? -
你为什么不用
LinearLayout,看起来这正是你所需要的