java - 需要一些东西从主 Activity 向左滑动才能进入另一个 Activity

标签 java android xml android-studio

我正在制作一个 Android 启动器,它只有应用程序名称(图标被隐藏,因为我只是希望它非常简约。

在主要 Activity 中,我有一个 GridView 中安装的所有应用程序的列表。 (我想更改它以仅显示选定的 Collection 应用程序)

我还有另一项 Activity ,其中所有应用程序都显示有搜索功能。

我希望能够从“主要 Activity ”切换到“完整应用程序”页面,以及通过滑动切换回“主要 Activity ”。

所以向左滑动应该带来具有(应用程序的GridView)的应用程序页面 从该页面向右滑动可以让我返回(希望恢复之前的 Activity )

我尝试了几种不同的解决方案,没有一个是理想的,因为大多数都不起作用,并且只有从顶部向右滑动时才有效。

Swipe left-right changes activity

我已经尝试了上面链接中提供的第一个解决方案

Main Activity Page where I want to swipe left App Activity Page where I want to swipe right

<?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/

相关文章:

android - Android TV 应用程序安装后无法打开

sql - 将具有相同标签的 XML 值分隔到不同的行 SQL Server

java - Tomcat 即服务与 64 位 Windows 控制台上的 Tomcat

java - Java 中 SQL 查询不解析整个表的方法 - JDBC

java - 如何向 Java 添加(次要的)语法糖?

android - 如何在 OkHttp 3 中为特定服务设置不同的连接超时?

android - 启用 android :hardwareAccelerated, 但针对早于 3.0 的目标构建

java - Map 类的 onCreate() 和 onMapReady() 函数从未运行

java - 最新的 Open JDK 8 JAXB 库无法解码具有包含换行符的属性的对象

java - 实体管理器未持久保存在数据库中