gpt4 book ai didi

Android layout_below 不工作

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:19:48 25 4
gpt4 key购买 nike

我在我的应用程序中广泛使用 RelativeLayouts,并认为我知道如何指定它们,但这让我不知所措。我基本上将 4 个 TextViews 放置在两行中,每行两行,每行包含一个标签和将提供的文本。它应该看起来像:

出生日期:1810 年 8 月 23 日,肯塔基州梅森公司

卒于:1865 年 7 月 15 日,俄亥俄州汉密尔顿市辛辛那提

这是布局的相关部分:

        <TextView android:id="@+id/birth_lbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/given_layout"
android:layout_alignLeft="@+id/given_layout"
android:layout_marginTop="6dip"
style="@style/label"
android:text="@string/born"
/>
<TextView android:id="@+id/birth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/birth_lbl"
android:layout_alignBaseline="@+id/birth_lbl"
android:layout_marginLeft="10dip"
android:layout_marginRight="6dip"
style="@style/main_text"
android:text="dd Mmm yy"
/>
<TextView android:id="@+id/death_lbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/birth"
android:layout_alignLeft="@+id/birth_lbl"
android:layout_marginTop="4dip"
style="@style/label"
android:text="@string/died"
/>
<TextView android:id="@+id/death"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/death_lbl"
android:layout_alignLeft="@+id/birth"
android:layout_alignBaseline="@+id/death_lbl"
android:layout_marginRight="6dip"
style="@style/main_text"
android:text="dd Mmm yy"
/>

出于某种原因,这会在出生线 View 上方显示死亡线 View !如果我将 death_lbl View 的规范更改为“layout_below="@+id/birth_lbl"',则线条定位正确!但是,“birth” View 有可能换行到多行,所以我确实需要将第 2 行放在“birth”下方,而不是“birth_lbl”。

有人知道这种行为的原因吗?它既出现在 Eclipse 的图形布局编辑器中,也出现在我运行 Android 4.0 的平板电脑上的运行时。

最佳答案

尝试将 death_lbl 中的 android:layout_below="@+id/birth" 更改为 android:layout_below="@id/birth" ,因为此时它已经被声明,+ 暗示,再次声明它可能会导致问题。

关于Android layout_below 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9351987/

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