Reputation: 271
I create a xml file presentation_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="@+id/top"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="horizontal"
>
<TextView
android:text="..."
android:id="@+id/txtDate"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
<LinearLayout
android:layout_below="@id/top"
android:layout_above="@id/bottom"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:orientation="vertical"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/img1"
android:contentDescription="@string/shop"
android:src="@drawable/ic_launcher"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/img2"
android:contentDescription="@string/shop"
android:src="@drawable/ic_launcher"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/img3"
android:contentDescription="@string/shop"
android:src="@drawable/ic_launcher"
/>
</LinearLayout>
<LinearLayout
android:layout_below="@id/top"
android:layout_above="@id/bottom"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:orientation="vertical"
>
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/img4"
android:contentDescription="@string/shop"
android:src="@drawable/preloaderf1"
/>
</LinearLayout>
<LinearLayout
android:layout_below="@id/top"
android:layout_above="@id/bottom"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:orientation="vertical"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/img5"
android:contentDescription="@string/shop"
android:src="@drawable/ic_launcher"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/img6"
android:contentDescription="@string/shop"
android:src="@drawable/ic_launcher"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/img7"
android:contentDescription="@string/shop"
android:src="@drawable/ic_launcher"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/bottom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/level"
android:layout_marginLeft="15dp"
android:layout_marginRight="10dp"
android:textSize="25dp"
/>
<ProgressBar
android:id="@+id/proBar"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:layout_marginRight="15dp"
android:progress="50"
android:max="100"
/>
</LinearLayout>
</RelativeLayout>
what is the error ? I built >>> R cannot resolve ?
Layout design is as follows,
xml file id error ?
Upvotes: 0
Views: 217
Reputation: 39
Please check that you have images in your drawable folder with capital letters or any incorrect format. It causes the loosing of R.java file.
If you can't find where the error is, just restart the eclipse and see console. It shows where the error is.
Upvotes: 0
Reputation: 16393
The first occurance of the id is the one that has to have the "+", whether it is the widget or a reference to the wiidget.
<LinearLayout
android:layout_below="@id/top"
android:layout_above="@+id/bottom"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:orientation="vertical" >
The above is perfectly valid. When you get to the "bottom" widget, there you would just use @id/bottom
.
Upvotes: 0
Reputation: 18592
This might possibly be because you are referring an id @id/bottom
in the other top layouts as android:layout_above="@id/bottom"
even before it was declared. Don't try to refer ids before they are declared. Check this link which gives more light on this issue:
http://developer.android.com/guide/topics/ui/layout-objects.html#relativelayout
Declare the linear layout with @id/bottom
just below the linear layout with @+id/top
and this should solve your problem.
Upvotes: 1