本文整理汇总了Java中android.widget.ScrollView.setPadding方法的典型用法代码示例。如果您正苦于以下问题:Java ScrollView.setPadding方法的具体用法?Java ScrollView.setPadding怎么用?Java ScrollView.setPadding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.ScrollView
的用法示例。
在下文中一共展示了ScrollView.setPadding方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setChromeRestrictions
import android.widget.ScrollView; //导入方法依赖的package包/类
/**
* Sets restrictions to Chrome
*/
private void setChromeRestrictions() {
final Activity activity = getActivity();
if (null == activity) {
return;
}
final DevicePolicyManager manager =
(DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
final Bundle settings = new Bundle();
settings.putString("EditBookmarksEnabled", "false");
settings.putString("IncognitoModeAvailability", "1");
settings.putString("ManagedBookmarks",
"[{\"name\": \"Chromium\", \"url\": \"http://chromium.org\"}, " +
"{\"name\": \"Google\", \"url\": \"https://www.google.com\"}]");
settings.putString("DefaultSearchProviderEnabled", "true");
settings.putString("DefaultSearchProviderName", "\"LMGTFY\"");
settings.putString("DefaultSearchProviderSearchURL",
"\"http://lmgtfy.com/?q={searchTerms}\"");
settings.putString("URLBlacklist", "[\"example.com\", \"example.org\"]");
StringBuilder message = new StringBuilder("Setting Chrome restrictions:");
for (String key : settings.keySet()) {
message.append("\n");
message.append(key);
message.append(": ");
message.append(settings.getString(key));
}
ScrollView view = new ScrollView(activity);
TextView text = new TextView(activity);
text.setText(message);
int size = (int) activity.getResources().getDimension(R.dimen.activity_horizontal_margin);
view.setPadding(size, size, size, size);
view.addView(text);
new AlertDialog.Builder(activity)
.setView(view)
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
// This is how you can set restrictions to an app.
// The format for settings in Bundle differs from app to app.
manager.setApplicationRestrictions
(BasicDeviceAdminReceiver.getComponentName(activity),
PACKAGE_NAME_CHROME, settings);
Toast.makeText(activity, R.string.restrictions_set,
Toast.LENGTH_SHORT).show();
}
})
.show();
}