gpt4 book ai didi

android - 是否可以通过编程方式启用 "Show layout bounds"开发人员选项?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:05:46 27 4
gpt4 key购买 nike

例如,我可以使用以下方式操作 ADB 调试:

Settings.Secure.putInt(getActivity().getContentResolver(),Settings.Secure.ADB_ENABLED, 1);

是否可以以类似的方式启用“显示布局边界”选项?我找不到任何关于它的文档。

最佳答案

不,据我所知,它不可用。但是,我做过的一件事是对所有 View 进行着色,以查看它们的绑定(bind)位置和重叠位置等。您可以使用此代码,它使用 droidQuery用于选择要迭代的所有 View 的库:

public static void debugLayout(View layout)
{
$.with(layout).selectAll().each(new Function() {
@Override
public void invoke($ d, Object... args) {
View v = d.view(0);
Drawable drawable = v.getBackground();
if (drawable != null)
drawable.setColorFilter(0xAAFF0000, PorterDuff.Mode.MULTIPLY);
else
drawable = new ColorDrawable(0xAAFF0000);
try {
//API 16+
v.setBackground(drawable);
}
catch (Throwable t) {
v.setBackgroundDrawable(drawable);
}
}
});
}

关于android - 是否可以通过编程方式启用 "Show layout bounds"开发人员选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18848507/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com