加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

RelativeLayout中的循环依赖关系不能存在,android?

发布时间:2020-12-14 04:32:28 所属栏目:百科 来源:网络整理
导读:我有以下布局: 我需要将按钮保留在屏幕的底部,并且应该对用户可见。 布局的其余部分应该滚动。 RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_p
我有以下布局:
我需要将按钮保留在屏幕的底部,并且应该对用户可见。
布局的其余部分应该滚动。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.vfc.sargroup.SalesOrderActivity$PlaceholderFragment" >

<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/bottomLinearLayout" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Select Distributor Name"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <Spinner
            android:id="@+id/spinner1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Payment Collection"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10" >
        </EditText>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Product Category"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10" >

            <requestFocus />
        </EditText>

        <TableLayout
            android:id="@+id/salesTableLayout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:stretchColumns="*" >
        </TableLayout>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Total QTY"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10" >

            <requestFocus />
        </EditText>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Total Price"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10" >

            <requestFocus />
        </EditText>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Remark"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10" >
        </EditText>
    </LinearLayout>
</ScrollView>

<LinearLayout
    android:id="@+id/bottomLinearLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_below="@+id/scrollView1"
    android:layout_centerHorizontal="true"
    android:orientation="vertical" >

    <Button
        android:id="@+id/button1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Submit" />
</LinearLayout>
  </RelativeLayout>

我只需要滚动我的视图,并保持按钮出现在屏幕底部。

问题在于

android:layout_above="@+id/bottomLinearLayout"

我得到错误

Circular dependencies cannot exist in RelativeLayout

我的布局有什么问题?

问题是由于布局参??数中有循环引用引起的。

例如,当视图B是layout_below视图A时,视图A不能再在下面引用视图B,alignRight等。这也可以存在于多个视图之间:引用B引用C.在这种情况下,C不能引用A因为循环依赖。

你使用: –

bottomLinearLayout在scrollView1下
然后你说scrollView1在bottomLinearLayout上面

它不会这样工作。使用一个

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读