2014-07-24 102 views
0

我想设计一个布局,但因为我无法理解,在设备中运行时出现错误。在相对布局中的Android框架布局关系

当我使用

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> 
+1

从'机器人取出加:ID = “@ + ID/frBottom”' – Blackbelt

+0

因为'@ + id用于/ ..'当你分配新的ID到一个视图和'@id/..'在您引用另一个视图时使用。 –

+0

@blackbelt你的意思是来自'android:layout_above =“@ + id/frBottom”'? – Pietu1998

回答

3

试试这个办法,希望这将帮助你解决你的问题。

<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/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> 

    <FrameLayout 
     android:id="@+id/frMain" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     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> 

</RelativeLayout> 
+0

thanx好主意:),它的工作! –

+0

@RehaOzenc - 将永远工作! –

+0

很高兴帮助你,你可以请批准答案,所以它可能会帮助其他人谢谢。 –