How to view the layout level in Android Studio

1. Use the Layout Inspector that comes with Android Studio;

2. Use the UI Automator Viewer in the SDK toolkit;

3. Use the dumpsys command

Through adb shell dumpsys activity topthe command, activitythe snapshot obtained contains layout information inside.

You can also obtain only the Activity information of your own application by specifying the package name:

adb shell dumpsys activity com.ldd.layoutapp(包名)

E:\Android\AndroidStudioProjects\LayoutApp>adb shell dumpsys activity com.ldd.layoutapp
TASK 10123:com.ldd.layoutapp id=89 userId=0
  ACTIVITY com.ldd.layoutapp/.MainActivity a6fb414 pid=15302
    Local Activity ba99d88 State:
      mResumed=true mStopped=false mFinished=false
      mIsInMultiWindowMode=false mIsInPictureInPictureMode=false
      mChangingConfigurations=false
      mCurrentConfig={1.0 310mcc260mnc [en_US] ldltr sw432dp w432dp h792dp 400dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1080, 2160) mAppBounds=Rect(
0, 0 - 1080, 2040) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=standard mAlwaysOnTop=undefined mRotation=ROTATION_0} s.1}
      mLoadersStarted=true
      Active Fragments in 104513d:
        #0: ReportFragment{1c55d32 #0 androidx.lifecycle.LifecycleDispatcher.report_fragment_tag}
          mFragmentId=#0 mContainerId=#0 mTag=androidx.lifecycle.LifecycleDispatcher.report_fragment_tag
          mState=5 mIndex=0 mWho=android:fragment:0 mBackStackNesting=0
          mAdded=true mRemoving=false mFromLayout=false mInLayout=false
          mHidden=false mDetached=false mMenuVisible=true mHasMenu=false
          mRetainInstance=false mRetaining=false mUserVisibleHint=true
          mFragmentManager=FragmentManager{104513d in HostCallbacks{a1a1a83}}
          mHost=android.app.Activity$HostCallbacks@a1a1a83
          Child FragmentManager{5836400 in ReportFragment{1c55d32}}:
            FragmentManager misc state:
              mHost=android.app.Activity$HostCallbacks@a1a1a83
              mContainer=android.app.Fragment$1@969c439
              mParent=ReportFragment{1c55d32 #0 androidx.lifecycle.LifecycleDispatcher.report_fragment_tag}
              mCurState=5 mStateSaved=false mDestroyed=false
      Added Fragments:
        #0: ReportFragment{1c55d32 #0 androidx.lifecycle.LifecycleDispatcher.report_fragment_tag}
      FragmentManager misc state:
        mHost=android.app.Activity$HostCallbacks@a1a1a83
        mContainer=android.app.Activity$HostCallbacks@a1a1a83
        mCurState=5 mStateSaved=false mDestroyed=false
    ViewRoot:
      mAdded=true mRemoved=false
      mConsumeBatchedInputScheduled=false
      mConsumeBatchedInputImmediatelyScheduled=false
      mPendingInputEventCount=0
      mProcessInputEventsScheduled=false
      mTraversalScheduled=false      mIsAmbientMode=false      mUnbufferedInputSource=0
      android.view.ViewRootImpl$NativePreImeInputStage: mQueueLength=0
      android.view.ViewRootImpl$ImeInputStage: mQueueLength=0
      android.view.ViewRootImpl$NativePostImeInputStage: mQueueLength=0
    Choreographer:
      mFrameScheduled=false
      mLastFrameTime=54431098 (840399 ms ago)

InsetsController:
      InsetsState
        InsetsSource type=ITYPE_STATUS_BAR frame=[0,0][1080,60] visible=true
        InsetsSource type=ITYPE_NAVIGATION_BAR frame=[0,2040][1080,2160] visible=true
        InsetsSource type=ITYPE_TOP_GESTURES frame=[0,0][1080,60] visible=true
        InsetsSource type=ITYPE_BOTTOM_GESTURES frame=[0,2040][1080,2160] visible=true
        InsetsSource type=ITYPE_LEFT_GESTURES frame=[0,0][0,2160] visible=true
        InsetsSource type=ITYPE_RIGHT_GESTURES frame=[1080,0][1080,2160] visible=true
        InsetsSource type=ITYPE_TOP_TAPPABLE_ELEMENT frame=[0,0][1080,60] visible=true
        InsetsSource type=ITYPE_BOTTOM_TAPPABLE_ELEMENT frame=[0,2040][1080,2160] visible=true
        InsetsSource type=ITYPE_IME frame=[0,0][0,0] visible=false
    View Hierarchy:
      DecorView@8e81a7e[MainActivity]
        android.widget.LinearLayout{e59dbdf V.E...... ........ 0,0-1080,2040}
          android.view.ViewStub{abac02c G.E...... ......I. 0,0-0,0 #10201af android:id/action_mode_bar_stub}
          android.widget.FrameLayout{6196af5 V.E...... ........ 0,60-1080,2040}
            androidx.appcompat.widget.ActionBarOverlayLayout{5e7608a V.E...... ........ 0,0-1080,1980 #7f08007d app:id/decor_content_parent}
              androidx.appcompat.widget.ContentFrameLayout{7aa56fb V.E...... ........ 0,140-1080,1980 #1020002 android:id/content}
                android.widget.LinearLayout{b29b318 V.E...... ........ 0,0-1080,1840}
                  com.google.android.material.textview.MaterialTextView{1e2c171 VFED..C.. ........ 0,0-387,97 #7f08006f app:id/constraintLayoutAct1}
                  com.google.android.material.textview.MaterialTextView{2e2fb56 VFED..C.. ........ 0,97-507,194 #7f08014f app:id/singleInstanceAct}
                  com.google.android.material.textview.MaterialTextView{dbd67d7 V.ED..... ........ 0,194-350,345 #7f08017d app:id/text}
              androidx.appcompat.widget.ActionBarContainer{692e8c4 V.ED..... ........ 0,0-1080,140 #7f080032 app:id/action_bar_container}
                androidx.appcompat.widget.Toolbar{b1103ad V.E...... ........ 0,0-1080,140 #7f080030 app:id/action_bar}
                  androidx.appcompat.widget.AppCompatTextView{a2b76e2 V.ED..... ........ 40,36-284,103}
                  androidx.appcompat.widget.ActionMenuView{786aa73 V.E...... ........ 1080,0-1080,140}
                androidx.appcompat.widget.ActionBarContextView{437cd30 G.E...... ......I. 0,0-0,0 #7f080038 app:id/action_context_bar}
        android.view.View{f672da9 V.ED..... ........ 0,2040-1080,2160 #1020030 android:id/navigationBarBackground}
        android.view.View{88e1f2e V.ED..... ........ 0,0-1080,60 #102002f android:id/statusBarBackground}
    Looper (main, tid 2) {d977acf}
      (Total messages: 0, polling=false, quitting=false)

The View Hierarchy: part inside is the complete hierarchical structure of your Activity layout.

Guess you like

Origin blog.csdn.net/hnjcxy/article/details/124129843