gpt4 book ai didi

android - 如何使用拉边手势调整 View 大小?

转载 作者:太空宇宙 更新时间:2023-11-03 12:28:16 27 4
gpt4 key购买 nike

我正在寻找如下图所示的解决方案:

enter image description here

我需要在一个布局中有两个可调整大小的 View 。用户只需将分隔线移动到顶部(ScrolView B 变得更高)或底部(ScrolView A 变得更高)。

给出这种行为的最佳解决方案是什么?我知道我可以从 ScrollView 扩展并覆盖 public boolean onTouchEvent(MotionEvent ev)protected void onDraw(Canvas canvas),但可能有更简单的解决方案。我想避免计算移动的数学。感谢您提供任何信息。

最佳答案

如果你想快速解决这个问题,我建议你使用Split Pane Layout .

用法:

 <com.mobidevelop.spl.widget.SplitPaneLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:spl="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:id="@+id/splitPaneLayout"
android:layout_height="match_parent"
spl:splitterSize="12dp"
spl:orientation="vertical"
spl:splitterPosition="50%"
spl:splitterBackground="#781b23">

<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="" />

</ScrollView>

<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text=""/>

</ScrollView>

</com.mobidevelop.spl.widget.SplitPaneLayout>

我通过为纵向和横向模式创建两个 xml 解决了您的问题。对于纵向模式,我通过添加 spl:orientation="vertical" 将面板的方向设置为垂直,对于横向模式,我通过添加 spl:orientation="horizo​​ntal"将面板的方向设置为水平".

完成所有这些之后,我得到了如下所示的外观。 enter image description here enter image description here

关于android - 如何使用拉边手势调整 View 大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42142938/

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