【发布时间】:2012-07-05 16:12:17
【问题描述】:
<?xml version="1.0" encoding="utf-8"?>
<!-- Layout-Normal-Portrait -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/thumb_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<android.support.v4.view.ViewPager
android:id="@+id/mypager"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:layout_above="@id/sum_layout"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
</android.support.v4.view.ViewPager>
</RelativeLayout>
<RelativeLayout
android:id="@+id/sum_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@id/thumb_layout" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="6dp"
android:text="@string/lorem__ipsum"
android:textColor="@color/black" />
</RelativeLayout>
</RelativeLayout>
我一运行程序,它就会在编辑器中显示一个错误,说“错误:错误:找不到与给定名称匹配的资源(在'layout_above',值为'@id/sum_layout')。 ”,在此代码的第 22 行。
谁能告诉我怎么了?
【问题讨论】:
-
您找到错误:找不到资源,因为它没有获得您想要在其上方设置的布局的 id。首先添加具有 id @+id/sum_layout 的布局,然后在上方添加 viewpager具有 id @+id/sum_layout 的布局。
标签: android textview android-relativelayout android-viewpager vertical-alignment