0
<?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"
android:padding="20dp">

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/content">

<ImageView
android:id="@+id/idcontentline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|top"
android:src="@drawable/line"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_centerHorizontal="true"/>

<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/idcontentline"
android:layout_centerHorizontal="true"
android:scrollbarStyle="insideInset"
android:scrollbars="vertical" >

<TextView
android:id="@+id/idcontenttext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="this is a sample" />

</ScrollView>

</RelativeLayout>

</RelativeLayout>

Android:layout_below="@+id/idcontentline" を使用すると、すべてが正しく、textview は imageview の下にあります。ただし、@+id の代わりに @id を使用すると、機能しません。

どうしたの?

4

2 に答える 2

3

文字列の先頭にあるアットマーク (@) は、XML パーサーが ID 文字列の残りを解析して展開し、それを ID リソースとして識別する必要があることを示します。プラス記号 (+) は、これが作成され、リソース (R.java ファイル内) に追加される必要がある新しいリソース名であることを意味します。Android フレームワークによって提供されるその他の ID リソースが多数あります。Android リソース ID を参照する場合、プラス記号は必要ありませんが、android パッケージの名前空間を追加する必要があります。

于 2012-10-29T07:04:51.057 に答える
0

プロジェクトを数回クリーンアップします。

于 2012-10-29T12:01:06.787 に答える