0

I have a ScrollView that contains a TextView, and a Spinner. I'd like to place the ScrollView directly above the Spinner. My code is giving me an error when I try to run the project, however:

Error:(11, 31) No resource found that matches the given name (at 'layout_above' with value '@id/tense_spinner').

Here is my code:

<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" 
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.wsandhu.conjugation.LearnActivity$PlaceholderFragment">

<ScrollView
    android:id="@+id/scrollview"
    android:layout_above="@id/tense_spinner"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
<TextView android:text="Placeholder text"
    android:id="@+id/learn_textview"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
</ScrollView>

<Spinner
    android:id="@+id/tense_spinner"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true" />

</RelativeLayout>

Any idea?

wasimsandhu
  • 4,296
  • 9
  • 27
  • 40

1 Answers1

4

try this..

replace this line

android:layout_above="@id/tense_spinner"

by this line

android:layout_above="@+id/tense_spinner"

also check this

Difference between "@id/" and "@+id/" in Android

edit

OR use linear layout instead

<LinearLayout 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"
    android:orientation="vertical"
    android:weightSum="4"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.wsandhu.conjugation.LearnActivity$PlaceholderFragment" >

    <ScrollView
        android:id="@+id/scrollview"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="3" >

        <TextView
            android:id="@+id/learn_textview"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Placeholder text" />
    </ScrollView>

    <Spinner
        android:id="@+id/tense_spinner"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>

</LinearLayout>
Community
  • 1
  • 1
M S Gadag
  • 2,057
  • 1
  • 12
  • 15