作为一名安卓萌新,我一直希望有一个能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