For example, I can manipulate ADB debugging using:
Settings.Secure.putInt(getActivity().getContentResolver(),Settings.Secure.ADB_ENABLED, 1);
Is it possible to enable the "Show layout bounds" option in a similar manner? I haven't been able to find any documentation on it.
Enable developer options and USB debugging On Android 4.1 and lower, the Developer options screen is available by default. On Android 4.2 and higher, you must enable this screen. To enable developer options, tap the Build Number option 7 times.
On Android, we have an option called Show layout bounds , which allows us to see bounding areas of your views displayed in vibrant blue and purple.
No, AFAIK it is not available. One thing I have done, however, is tint all my views to see where they are bound and where they overlap, etc. You can use this code, which uses the droidQuery library to select all views to iterate over:
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);
}
}
});
}
There may be something you can do to simulate what the Settings code actually does:
https://github.com/android/platform_packages_apps_settings/blob/master/src/com/android/settings/DevelopmentSettings.java#L942
private void writeDebugLayoutOptions() {
SystemProperties.set(View.DEBUG_LAYOUT_PROPERTY,
mDebugLayout.isChecked() ? "true" : "false");
pokeSystemProperties();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With