簡體   English   中英

需要從主活動向左輕掃以進入其他活動

[英]Need something Swipe Left from Main Activity to go into another Activity

我正在制作一個僅具有應用程序名稱的Android啟動器(圖標被隱藏了,因為我只是希望它非常簡單。

在主要活動中,我列出了GridView中安裝的所有應用程序。 (我想將其更改為僅顯示選定的收藏夾應用程序)

我還有另一項活動,其中所有應用程序都顯示有搜索功能。

我希望能夠從“主要活動”切換到“完整應用”頁面,以及通過滑動切換回“主要活動”。

因此,向左滑動即可帶動從該頁面向右滑動(應用程序的GridView)的應用程序頁面(希望恢復上一個活動)

我嘗試了幾種不同的解決方案,但都不是理想的解決方案,因為大多數解決方案都無效,並且只有從頂部開始滑動才可以解決。

左右滑動更改活動

我已經嘗試了上面鏈接中提供的第一個解決方案

我要向左滑動的主要活動頁面 我要向右滑動的應用活動頁面

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

嗨,看看吧,嘗試一下此操作,使手勢指向左下右,然后在左側區域中調用您的下一個活動意圖:Android:如何處理從右向左滑動的手勢

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM