我想知道是否有人可以解释我遇到的一个小问题。我试图让我的周围RelativeLayouts头,有以下几点:ImageViews和TextViews在相对布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:orientation="vertical"
android:background="#ffffff"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/newsImage"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_alignParentLeft="true"
android:background="#ffffff" >
</ImageView>
<TextView
android:id="@+id/newsSubtitle"
android:layout_height="fill_parent"
android:layout_width="200dp"
android:textColor="#0098bf"
android:layout_centerVertical="true"
android:layout_alignRight="@+id/newsImage"
android:textSize="18sp">
</TextView>
<TextView
android:id="@+id/newsId"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:visibility="invisible"
android:textSize="0sp" >
</TextView>
</RelativeLayout>
正如我在RelativeLayouts理解它,你可以对齐孩子使用“alignParentLeft =‘真’”父(RelativeLayout的),你可以使用alignRight =“@ + id/childId”将每个孩子与其他孩子对齐。对于TextViews来说这似乎工作得很好,但是我无法让我的ImageViews正常工作 - 这就好像它们实际上似乎没有占用任何空间,因为TextView只是坐在图像的顶部,而不是对齐到图像的权利。
我在这里误解了一些东西吗?RelativeLayouts有不同的对齐图像/文本组合的方法吗?
我已经在TextView中做了这个 'android:layout_alignRight =“@ + id/newsImage”' 我也尝试删除+号,但那也没用。 –
+符号表示当您要调用现有的ID时,您正在创建一个新的ID。将来不要在引用另一个视图时使用加号。如果图像很大,那么textview会重叠,但代码仍然可以工作。尝试使用ic_launcher(应用程序图标)作为要检测的图像视图的来源。 –