0
我正在开发一个像编辑器一样工作的应用程序,并且可以将元素拖放到布局中,但我需要我的布局尺寸有时比屏幕尺寸大,所以我需要在布局上以两种方式进行滚动。2维滚动视图内的相对布局当视图添加到布局的极限时,它将调整其自身的大小
我做这样的:
<ScrollView
android:id="@+id/layoutScroll"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="16dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
app:layout_constraintBottom_toTopOf="@+id/trashBtn"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/LabelTypeTextView"
>
<HorizontalScrollView
android:id="@+id/layoutScrollHor"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:id="@+id/labelCanvas"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:clipToPadding="false"
android:clipChildren="false"
android:background="@drawable/label_canvas"
app:layout_constraintBottom_toTopOf="@+id/trashBtn"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/LabelTypeTextView">
</RelativeLayout>
</HorizontalScrollView>
</ScrollView>
的问题是,当我一个元素添加到我的相对布局结束,布局增加了它的尺寸,我想它只是夹元素。
视觉举例: Example
这里的粉红色行是布局结束,但是当我拖着元素,它不能够完全留它会调整布局将布局内的位置蓝色的空间。
有什么建议吗?
谢谢你的答案,但我已经尝试过,并没有工作... –