作为一名安卓萌新,我一直希望有一个能3D观察Ui层的工具,机缘巧合我追寻到了JakeWharton大神的Scalpel。
效果图:

以下是在Android Studio IDE下使用该工具的教程
首先,在添加依赖:
compile 'com.jakewharton.scalpel:scalpel:1.1.2'
使用的时候你的layout根节点必须是 ScalpelFrameLayout
在OnCreate方法中:
View mainView = getLayoutInflater().inflate(R.layout.activity_main, null); ScalpelFrameLayout mScalpelFrameLayout = new ScalpelFrameLayout(this); mScalpelFrameLayout.addView(mainView); mScalpelFrameLayout.setLayerInteractionEnabled(true); mScalpelFrameLayout.setDrawIds(true); mScalpelFrameLayout.setDrawViews(true); setContentView(mScalpelFrameLayout);
常用方法:
-
开启3D效果 : setLayerInteractionEnabled(boolean).
-
显隐DrawViews:setDrawViews(boolean).
-
显隐 view ID: setDrawIds(boolean).
-
修改边框的颜色和阴影 setChromeColor(int) and setChromeShadowColor(int).
手势功能:
-
单点触摸:可以控制其旋转角度。
-
两指垂直滑动:可以放大或缩小。
-
两指水平滑动:可以调整布局层次之间的间距,清晰看到深层次的布局结构。
详情你可以看JakeWharton大神的Github
本文介绍了Android开发者JakeWharton创建的Scalpel工具,它允许开发者以3D方式查看和理解UI布局。通过添加依赖、设置交互及颜色,开发者可以实现界面的3D展示,包括旋转、缩放和调整布局层次间距等功能,便于深入检查布局结构。

2550

被折叠的 条评论
为什么被折叠?



