Android 13 设置界面会判断当前屏幕的大小,如果是大屏,则为双栏显示!
我的博客
./packages/apps/Settings/src/com/android/settings/homepage/SettingsHomepageActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mIsEmbeddingActivityEnabled = ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this);//这里来进行判断
if (mIsEmbeddingActivityEnabled) {
final UserManager um = getSystemService(UserManager.class);
final UserInfo userInfo = um.getUserInfo(getUser().getIdentifier());
if (userInfo.isManagedProfile()) {
final Intent intent = new Intent(getIntent())
.setClass(this, DeepLinkHomepageActivityInternal.class)
.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT)
.putExtra(EXTRA_USER_HANDLE, getUser());
intent.removeFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivityAsUser(intent, um.getPrimaryUser().getUserHandle());
finish();
return;
}
}
setupEdgeToEdge();
setContentView(R.layout.settings_homepage_container);
...
/packages/apps/Settings/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java
/** Whether to support embedding activity feature. */
public static boolean isEmbeddingActivityEnabled(Context context) {
//update text
final boolean isFlagEnabled = false;//FeatureFlagUtils.isEnabled(context,FeatureFlagUtils.SETTINGS_SUPPORT_LARGE_SCREEN);
final boolean isSplitSupported = SplitController.getInstance().isSplitSupported();
Log.d(TAG, "isFlagEnabled = " + isFlagEnabled);
Log.d(TAG, "isSplitSupported = " + isSplitSupported);
return isFlagEnabled && isSplitSupported;
}
//当isFlagEnabled和isSplitSupported都为true时为双栏显示,反之则单栏,&&表示可以只修改其中一个为false就ok了