有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java为什么是安卓:layout_在java中不起作用

我有这个布局

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

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

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

我希望bottom_container位于我的ListView下方

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

enter image description here


共 (1) 个答案

  1. # 1 楼答案

    你的问题很不完整,但我在你的xml中看到了一些关于“上面”的潜在错误

    比如

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

    这是一个错误,您不能声明将父项顶部和末端对齐。。。不管怎样,如果我是对的,上面的那些ovverride布局