And*_*rew 20 android android-relativelayout
有人可以向我解释为什么ImageView没有出现在LinearLayout上面吗?
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/rev_main"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<!-- some stuff in here -->
</LinearLayout>
<ImageView
android:id="@+id/rev_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/arrow"
android:layout_above="@id/rev_main"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我不明白.
Err*_*454 25
指定相对于另一个布局的对齐时会发生这种情况.我找到的解决方案是走向另一个方向.
而不是告诉ImageView在LinearLayout之上,告诉LinearLayout在ImageView下面.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/rev_main"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/rev_arrow">
<!-- some stuff in here -->
</LinearLayout>
<ImageView
android:id="@+id/rev_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/arrow"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
以下内容对您有用:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/rev_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/arrow"
android:layout_alignParentTop="true"
/>
<LinearLayout
android:id="@+id/rev_main"
android:layout_width="fill_parent"
android:layout_below="@id/rev_arrow"
android:layout_height="wrap_content">
<!-- some stuff in here -->
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
65952 次 |
| 最近记录: |