【发布时间】:2019-08-29 12:32:56
【问题描述】:
我正在制作一个 Android 启动器,它只有应用程序名称(图标被隐藏,因为我只是希望它非常简约。
在主要活动中,我有一个 GridView 中安装的所有应用程序的列表。 (我想将其更改为仅显示选定的收藏应用程序)
我还有另一个活动,其中所有应用都显示为具有搜索功能。
我希望能够从主活动切换到完整应用页面,以及通过滑动切换回主活动。
所以向左滑动应该会带来具有(应用程序的 GridView)的应用程序页面 从该页面向右滑动让我回来(希望恢复以前的活动)
我尝试了几种不同的解决方案,但没有一个是理想的,因为大多数都不起作用,而且只有从顶部向右滑动时才有效。
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>
【问题讨论】:
标签: java android xml android-studio