我正在制作一个 Android 启动器,它只有应用程序名称(图标被隐藏,因为我只是希望它非常简约。
在主要 Activity 中,我有一个 GridView 中安装的所有应用程序的列表。 (我想更改它以仅显示选定的 Collection 应用程序)
我还有另一项 Activity ,其中所有应用程序都显示有搜索功能。
我希望能够从“主要 Activity ”切换到“完整应用程序”页面,以及通过滑动切换回“主要 Activity ”。
所以向左滑动应该带来具有(应用程序的GridView)的应用程序页面 从该页面向右滑动可以让我返回(希望恢复之前的 Activity )
我尝试了几种不同的解决方案,没有一个是理想的,因为大多数都不起作用,并且只有从顶部向右滑动时才有效。
Swipe left-right changes activity
我已经尝试了上面链接中提供的第一个解决方案
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/MainActivity"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical">
<LinearLayout
android:id="@+id/top_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextClock
android:id="@+id/clock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:textSize="40sp" />
<TextView
android:id="@+id/dateView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/MainActivityApp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="6">
<GridView
android:id="@+id/appGrids"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="1"
android:stretchMode="columnWidth">
</GridView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="2">
<ImageView
android:id="@+id/setting"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:contentDescription="@string/app_name"
app:srcCompat="@android:drawable/ic_menu_manage"
/>
</LinearLayout>
</LinearLayout>
最佳答案
您好,看看并尝试向左右下角手势,并在左侧部分调用您的下一个 Activity Intent Android: How to handle right to left swipe gestures
关于java - 需要一些东西从主 Activity 向左滑动才能进入另一个 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57660703/