我正在寻找如下图所示的解决方案:
我需要在一个布局中有两个可调整大小的视图。
用户只需将分隔线移动到顶部(ScrollView B 变得更高)或底部(ScrollView A 变得更高)。
给出这种行为的最佳解决方案是什么?我知道我可以从 ScrollView 扩展并覆盖public boolean onTouchEvent(MotionEvent ev)
and protected void onDraw(Canvas canvas)
,但可能有更简单的解决方案。我想避免计算移动的数学。感谢您提供任何信息。
如果你想快速解决这个问题,我建议你使用分割窗格布局 https://github.com/MobiDevelop/android-split-pane-layout.
Usage :
<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="horizontal"
.
After doing all this, I got the look like below.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)