如何在android中使用手指移动隐藏和显示布局视图?
我是Android开发的新手。我正在开发一个虚拟应用程序,它使用与Bigo live app相同的概念(直播屏幕滑动动画)。在我的应用程序中,我想隐藏和显示包含一些视图的布局。当我从左向右滑动时,当前视图将隐藏,反之亦然,则显示隐藏视图。所有的工作都会影响我的手指运动。 我已经实现了Touch Listener。如何在android中使用手指移动隐藏和显示布局视图?,android,android-studio,Android,Android Studio,我是Android开发的新手。我正在开发一个虚拟应用程序,它使用与Bigo live app相同的概念(直播屏幕滑动动画)。在我的应用程序中,我想隐藏和显示包含一些视图的布局。当我从左向右滑动时,当前视图将隐藏,反之亦然,则显示隐藏视图。所有的工作都会影响我的手指运动。 我已经实现了Touch Listener。 任何类型的帮助都将不胜感激。我已经尝试使用。我添加了一个片段来播放视频,在片段的布局中,我添加了这个滑动抽屉,其中还包含一个片段,当抽屉打开或关闭时,该片段将充当覆盖层。让我解释一下:
任何类型的帮助都将不胜感激。我已经尝试使用。我添加了一个片段来播放视频,在片段的布局中,我添加了这个滑动抽屉,其中还包含一个片段,当抽屉打开或关闭时,该片段将充当覆盖层。让我解释一下: 我有一个视频片段,这是布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#000000"
tools:context=".ui.activity.VLCActivity">
<SurfaceView
android:id="@+id/surface"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="false"
android:layout_gravity="center" />
<ProgressBar
android:id="@+id/pb"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:visibility="gone" />
<!--</com.github.pedrovgs.DraggableView>-->
<include
android:id="@+id/include"
layout="@layout/actionbar_video_chat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"></include>
<com.github.ali.android.client.customview.view.SlidingDrawer
android:id="@+id/slidingDrawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:background="@android:color/transparent"
custom:offsetDistance="20px"
custom:stickTo="right">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/textchat"
android:name="com.projects.kaarthick.mluitests.ui.fragments.TextChatFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</com.github.ali.android.client.customview.view.SlidingDrawer>
对于自定义操作,必须覆盖以下方法:
@Override
public void onOpened()
{
Toast.makeText(getActivity(),"Slide left",Toast.LENGTH_SHORT).show();
}
@Override
public void onClosed()
{
Toast.makeText(getActivity(),"Slide right",Toast.LENGTH_SHORT).show();
}
这就是我能够做到的:
我已经尝试过使用。我添加了一个片段来播放视频,在片段的布局中,我添加了这个滑动抽屉,其中还包含一个片段,当抽屉打开或关闭时,该片段将充当覆盖层。让我解释一下: 我有一个视频片段,这是布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#000000"
tools:context=".ui.activity.VLCActivity">
<SurfaceView
android:id="@+id/surface"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="false"
android:layout_gravity="center" />
<ProgressBar
android:id="@+id/pb"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:visibility="gone" />
<!--</com.github.pedrovgs.DraggableView>-->
<include
android:id="@+id/include"
layout="@layout/actionbar_video_chat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"></include>
<com.github.ali.android.client.customview.view.SlidingDrawer
android:id="@+id/slidingDrawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:background="@android:color/transparent"
custom:offsetDistance="20px"
custom:stickTo="right">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/textchat"
android:name="com.projects.kaarthick.mluitests.ui.fragments.TextChatFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</com.github.ali.android.client.customview.view.SlidingDrawer>
对于自定义操作,必须覆盖以下方法:
@Override
public void onOpened()
{
Toast.makeText(getActivity(),"Slide left",Toast.LENGTH_SHORT).show();
}
@Override
public void onClosed()
{
Toast.makeText(getActivity(),"Slide right",Toast.LENGTH_SHORT).show();
}
这就是我能够做到的:
基本上:创建一个新的触摸监听器,在屏幕的左/右侧创建一个栏,当触摸和移动它时,您移动布局。基本上:创建一个新的触摸监听器,在屏幕的左/右侧创建一个栏,当触摸和移动它时,您移动布局。