gpt4 book ai didi

java - 为什么安卓是:layout_above doesn't work in

转载 作者:太空宇宙 更新时间:2023-11-04 14:15:41 25 4
gpt4 key购买 nike

我有这个布局

    <ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/comments_list" android:layout_gravity="center"
android:layout_below="@+id/phone_editText" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_above="@+id/bottom_container"
android:layout_alignRight="@+id/search_btn" android:layout_alignEnd="@+id/search_btn"/>
<AutoCompleteTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/phone_editText"
android:hint="enter phone"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="blocked"
android:id="@+id/isBlocked_cb"
android:layout_toStartOf="@+id/phone_editText"
android:layout_toLeftOf="@+id/phone_editText"
android:layout_above="@+id/comments_list"
android:checked="true" android:layout_alignParentTop="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="search"
android:id="@+id/search_btn"
android:layout_toEndOf="@+id/phone_editText"
android:layout_toRightOf="@+id/phone_editText"
android:layout_above="@+id/comments_list"
android:layout_alignParentTop="true" android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" android:onClick="foo"/>

<RelativeLayout android:id="@+id/bottom_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true">
<AutoCompleteTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/comment_text"
android:hint="enter comment"
android:layout_alignParentBottom="true" android:layout_centerHorizontal="true"/>

<Button style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Add" android:id="@+id/add_btn"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/comment_text" android:layout_alignTop="@+id/comment_text"/>
</RelativeLayout>
<LinearLayout
android:focusable="true" android:focusableInTouchMode="true"
android:layout_width="0px" android:layout_height="0px"/>
</RelativeLayout>

我希望 bottom_container 位于我的 ListView 下方

但在模拟器中,它们似乎一个比另一个高:

enter image description here

最佳答案

你的问题相当不完整,但我在你的 xml 中发现了一些关于“above”的潜在错误

例如

android:layout_above="@+id/comments_list"
android:layout_alignParentTop="true" android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" android:onClick="foo"/>

这是一个错误,你不能声明将父顶部和底部对齐...并且在任何情况下,如果我是对的,那些 ovverride 布局_above。

关于java - 为什么安卓是:layout_above doesn't work in,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27780435/

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