Java android:在ImageView不工作的情况下在下面进行布局
android:layout(s是否与Java android:在ImageView不工作的情况下在下面进行布局,java,android,layout,imageview,Java,Android,Layout,Imageview,android:layout(s是否与ImageViews一起工作?从图片中,您可以看到所有10行都在彼此的顶部,这意味着q2Image不接受下面的代码android:layout_=“@/q1Image”,以便它放下一行并在下一行加上星号 我只是错过了什么,还是我试图做一些不可能的事情 <ScrollView android:layout_width="fill_parent" android:layout_height="0dip" android:layout
ImageView
s一起工作?从图片中,您可以看到所有10行都在彼此的顶部,这意味着q2Image
不接受下面的代码android:layout_=“@/q1Image”
,以便它放下一行并在下一行加上星号
我只是错过了什么,还是我试图做一些不可能的事情
<ScrollView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="65"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/q1Image"
android:layout_width="10dp"
android:layout_height="10dp" />
<TextView
android:id="@+id/q1Question"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/q1Image" />
<TextView
android:id="@+id/q1Answer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/q1Question" />
<TextView
android:id="@+id/q1Verse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/q1Answer" />
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#C2BEBF" />
<ImageView
android:id="@+id/q2Image"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_below="@id/q1Image" />
<TextView
android:id="@+id/q2Question"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/q2Image" />
<TextView
android:id="@+id/q2Answer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/q2Question" />
<TextView
android:id="@+id/q2Verse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/q2Answer" />
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#C2BEBF" />
//Above code is first 2 rows. There are 10 rows total but I removed the code for rows 3-10 for this post.
//上面的代码是前2行。总共有10行,但是我删除了这篇文章第3-10行的代码。
引用Id是这样的,并不总是有效的。将“@id”替换为“@+id”。 例如:
尝试将+置于@和id之间,一切都必须正常
@+id
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<!-- here the columns -->
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<!-- here the columns -->
</LinearLayout>
.
.
</LinearLayout>
@+id
.
.
您在代码中访问ID的方式是正确的。“@+id”用于声明id。声明后对它的所有引用都应为“@id”。您在文本视图方面也有同样的问题吗?我认为您也应该为TextView设置layout_down属性。因为我可以看到文本在你的UI中也是重叠的。例如
<TextView
android:id="@+id/q2Question"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below = "@id/q1Question"
android:layout_toRightOf="@id/q2Image" />
RelativeLayout不会将一个视图放置在另一个视图的下方,除非您在下方为其指定布局。因此,您的文本视图看起来是重叠的。有关更多信息,请查看我阅读的这个问题,并尝试了两种方法,但都得到了相同的结果。转到eclipse中的图形布局,然后使用鼠标将其放置,改为编写代码…更改了所有实例以添加
+
,但结果相同。我使用相同的结果进行了清理和重建。更改了所有实例以添加+
,但结果相同。您的问题有屏幕视图吗?我认为有一个更简单的方法你所说的屏幕视图是什么意思?设计视图。布局必须看起来像什么atI没有一个,但基本上它是10行,每行4列。第0列是一个小图片(绿色复选标记或红色x),最后3列各为一个字符串。
<TextView
android:id="@+id/q2Question"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below = "@id/q1Question"
android:layout_toRightOf="@id/q2Image" />