当前位置: 首页>>代码示例>>Java>>正文


Java ScrollView.setPadding方法代码示例

本文整理汇总了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();
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:52,代码来源:BasicManagedProfileFragment.java


注:本文中的android.widget.ScrollView.setPadding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。