Java Code Examples for android.widget.ScrollView#setPadding()
The following examples show how to use
android.widget.ScrollView#setPadding() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivityUtils.java From memetastic with GNU General Public License v3.0 | 6 votes |
public void showDialogWithHtmlTextView(@StringRes int resTitleId, String text, boolean isHtml, DialogInterface.OnDismissListener dismissedListener) { ScrollView scroll = new ScrollView(_context); AppCompatTextView textView = new AppCompatTextView(_context); int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, _context.getResources().getDisplayMetrics()); scroll.setPadding(padding, 0, padding, 0); scroll.addView(textView); textView.setMovementMethod(new LinkMovementMethod()); textView.setText(isHtml ? new SpannableString(Html.fromHtml(text)) : text); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17); AlertDialog.Builder dialog = new AlertDialog.Builder(_context) .setPositiveButton(android.R.string.ok, null).setOnDismissListener(dismissedListener) .setView(scroll); if (resTitleId != 0) { dialog.setTitle(resTitleId); } dialogFullWidth(dialog.show(), true, false); }
Example 2
Source File: ActivityUtils.java From openlauncher with Apache License 2.0 | 6 votes |
public void showDialogWithHtmlTextView(@StringRes int resTitleId, String text, boolean isHtml, DialogInterface.OnDismissListener dismissedListener) { ScrollView scroll = new ScrollView(_context); AppCompatTextView textView = new AppCompatTextView(_context); int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, _context.getResources().getDisplayMetrics()); scroll.setPadding(padding, 0, padding, 0); scroll.addView(textView); textView.setMovementMethod(new LinkMovementMethod()); textView.setText(isHtml ? new SpannableString(Html.fromHtml(text)) : text); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17); AlertDialog.Builder dialog = new AlertDialog.Builder(_context) .setPositiveButton(android.R.string.ok, null).setOnDismissListener(dismissedListener) .setView(scroll); if (resTitleId != 0) { dialog.setTitle(resTitleId); } dialogFullWidth(dialog.show(), true, false); }
Example 3
Source File: RecoveryActivity.java From Recovery with Apache License 2.0 | 6 votes |
private void initView() { mMainLayout = findViewById(R.id.recovery_main_layout); mDebugLayout = findViewById(R.id.recovery_debug_layout); mRecoverBtn = (Button) findViewById(R.id.btn_recover); mRestartBtn = (Button) findViewById(R.id.btn_restart); mRestartClearBtn = (Button) findViewById(R.id.btn_restart_clear); mExceptionTypeTv = (TextView) findViewById(R.id.tv_type); mClassNameTv = (TextView) findViewById(R.id.tv_class_name); mMethodNameTv = (TextView) findViewById(R.id.tv_method_name); mLineNumberTv = (TextView) findViewById(R.id.tv_line_number); mStackTraceTv = (TextView) findViewById(R.id.tv_stack_trace); mCauseTv = (TextView) findViewById(R.id.tv_cause); mCrashTipsTv = (TextView) findViewById(R.id.tv_crash_tips); mScrollView = (ScrollView) findViewById(R.id.scrollView); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { mScrollView.setPadding(0, RecoveryUtil.dp2px(getApplication(), 16), 0, 0); } }
Example 4
Source File: CpuInfoActivity.java From DKVideoPlayer with Apache License 2.0 | 5 votes |
@Override protected View getContentView() { ScrollView scrollView = new ScrollView(this); scrollView.setPadding(PlayerUtils.dp2px(this, 20), 0, 0, 0); mCpuInfo = new TextView(this); mCpuInfo.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12); mCpuInfo.setTextColor(Color.BLACK); scrollView.addView(mCpuInfo); return scrollView; }
Example 5
Source File: ActivityUtils.java From kimai-android with MIT License | 5 votes |
public void showDialogWithHtmlTextView(@StringRes int resTitleId, String text, boolean isHtml, DialogInterface.OnDismissListener dismissedListener) { ScrollView scroll = new ScrollView(_context); AppCompatTextView textView = new AppCompatTextView(_context); int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, _context.getResources().getDisplayMetrics()); scroll.setPadding(padding, 0, padding, 0); scroll.addView(textView); textView.setMovementMethod(new LinkMovementMethod()); textView.setText(isHtml ? new SpannableString(Html.fromHtml(text)) : text); AlertDialog.Builder dialog = new AlertDialog.Builder(_context) .setPositiveButton(android.R.string.ok, null).setOnDismissListener(dismissedListener) .setTitle(resTitleId).setView(scroll); dialog.show(); }
Example 6
Source File: BasicManagedProfileFragment.java From enterprise-samples with Apache License 2.0 | 4 votes |
/** * 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(); }
Example 7
Source File: BasicManagedProfileFragment.java From android-BasicManagedProfile with Apache License 2.0 | 4 votes |
/** * 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(); }