当前位置:   article > 正文

Android13 控制设置界面 双栏显示或单栏显示

Android13 控制设置界面 双栏显示或单栏显示

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了
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/爱喝兽奶帝天荒/article/detail/911061
推荐阅读
相关标签
  

闽ICP备14008679号