Android分屏模式(Split-screen mode)是Android系统的一项实用功能,可以让用户同时在屏幕上显示两个应用,从而提高工作效率和多任务处理能力。
进入分屏模式的方法有多种,具体取决于Android版本和设备型号。以下是一些常见的方法:
长按最近使用的应用按钮: 在大多数Android设备上,长按最近使用的应用按钮即可显示最近使用的应用列表,然后拖动其中一个应用图标到屏幕边缘即可进入分屏模式。
使用手势: 在某些设备上,可以使用手势来进入分屏模式,例如向左或向右滑动屏幕边缘,或者使用三指下滑手势。
使用应用快捷方式: 某些应用支持分屏模式快捷方式,点击该快捷方式即可直接进入分屏模式。
https://blog.51cto.com/u_15162069/2763537
https://juejin.cn/post/7324384226932441124
resizeableActivity
screenLayout|orientation
<activity android:name=".MainActivity"
android:resizeableActivity="true"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
isInMultiWindowMode
onMultiWindowModeChanged
/**
* Called by the system when the activity changes from fullscreen mode to multi-window mode and
* visa-versa. This method provides the same configuration that will be sent in the following
* {@link #onConfigurationChanged(Configuration)} call after the activity enters this mode.
*
* @see android.R.attr#resizeableActivity
*
* @param isInMultiWindowMode True if the activity is in multi-window mode.
* @param newConfig The new configuration of the activity with the state
* {@param isInMultiWindowMode}.
*/
public void onMultiWindowModeChanged(boolean isInMultiWindowMode, Configuration newConfig) {
// Left deliberately empty. There should be no side effects if a direct
// subclass of Activity does not call super.
onMultiWindowModeChanged(isInMultiWindowMode);
}
/**
* Returns true if the activity is currently in multi-window mode.
* @see android.R.attr#resizeableActivity
*
* @return True if the activity is in multi-window mode.
*/
public boolean isInMultiWindowMode() {
return mIsInMultiWindowMode;
}
orientation
/**
* Called by the system when the device configuration changes while your
* activity is running. Note that this will <em>only</em> be called if
* you have selected configurations you would like to handle with the
* {@link android.R.attr#configChanges} attribute in your manifest. If
* any configuration change occurs that is not selected to be reported
* by that attribute, then instead of reporting it the system will stop
* and restart the activity (to have it launched with the new
* configuration).
*
* <p>At the time that this function has been called, your Resources
* object will have been updated to return resource values matching the
* new configuration.
*
* @param newConfig The new device configuration.
*/
public void onConfigurationChanged(@NonNull Configuration newConfig) {
if (DEBUG_LIFECYCLE) Slog.v(TAG, "onConfigurationChanged " + this + ": " + newConfig);
mCalled = true;
mFragments.dispatchConfigurationChanged(newConfig);
if (mWindow != null) {
// Pass the configuration changed event to the window
mWindow.onConfigurationChanged(newConfig);
}
if (mActionBar != null) {
// Do this last; the action bar will need to access
// view changes from above.
mActionBar.onConfigurationChanged(newConfig);
}
}