gpt4 book ai didi

android - 在相对布局中使用 layout_above

转载 作者:IT老高 更新时间:2023-10-28 23:10:48 26 4
gpt4 key购买 nike

有人可以向我解释为什么 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>

我不明白。

最佳答案

当您指定相对于另一个布局的对齐方式时,会发生这种情况。我找到的解决方案是另辟蹊径。

不是告诉 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>

关于android - 在相对布局中使用 layout_above,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5970773/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com