gpt4 book ai didi

android - 在android中将一个布局滑动到另一个布局上

转载 作者:行者123 更新时间:2023-12-04 00:36:37 61 4
gpt4 key购买 nike

我需要在 Android 中将一个布局滑动到另一个布局上。

要求。

1 . 布局 1 覆盖了 80% 的屏幕,其余部分由布局 2 占据。

enter image description here

2 .我需要能够在布局1之上滑动布局2, 布局 2 的总宽度或可滚动限制应该是这样的 布局 1 的 20% 应在下方可见。

enter image description here

3 .然后我需要将布局2滑回到其原始位置。

enter image description here

我尝试过可能的滑动教程,包括

Sliding Menu by Jfeinstein

Slide Panel Layout - Android

以及互联网上提供的许多其他教程。

这些都无法提供我所需要的,我尝试了很多自定义并花了将近一周的时间,

有人可以帮忙吗

最佳答案

明白了!!...简单是最好的。没有库,没有复杂的代码。使用 SimplePaneLayout。

只需将 android:layout_marginLeft 设置为合适的值即可。 :) 太棒了 :)

<android.support.v4.widget.SlidingPaneLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/slidingpanelayout">

<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#CCC"
android:orientation="horizontal"
android:id="@+id/fragment_firstpane"/>

<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"
android:orientation="horizontal"
android:layout_marginLeft="40dp"
android:id="@+id/fragment_secondpane"/>

</android.support.v4.widget.SlidingPaneLayout>

关于android - 在android中将一个布局滑动到另一个布局上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23732939/

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