List of usage examples for android.widget ScrollView ScrollView
public ScrollView(Context context)
From source file:com.google.adsensequickstart.DisplayReportFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ScrollView sv = new ScrollView(getActivity()); TableLayout tl = new TableLayout(getActivity()); sv.addView(tl);/*from w w w. j a v a2s. c o m*/ if (displayReportController == null) { return sv; } AdsenseReportsGenerateResponse response = displayReportController.getReportResponse(); TableLayout.LayoutParams tableRowParams = new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); tableRowParams.setMargins(10, 10, 10, 10); TableRow.LayoutParams tvParams = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); tvParams.setMargins(10, 10, 10, 10); List<Headers> headers = response.getHeaders(); TableRow tr = new TableRow(getActivity()); tl.addView(tr); for (Headers header : headers) { TextView tv = new TextView(getActivity()); tv.setText(header.getName()); tr.setLayoutParams(tableRowParams); tr.addView(tv); } if (response.getRows() != null && !response.getRows().isEmpty()) { for (List<String> row : response.getRows()) { TableRow trow = new TableRow(getActivity()); tl.addView(trow); for (String cell : row) { TextView tv = new TextView(getActivity()); tv.setText(cell); trow.addView(tv); tv.setLayoutParams(tvParams); tv.setPadding(15, 5, 15, 5); tv.setBackgroundColor(Color.WHITE); } } } return sv; }
From source file:com.art2cat.dev.moonlightnote.controller.settings.CommonSettingsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment if (getArguments() != null) { mType = getArguments().getInt("type"); }/*from w ww.j a va 2s .c om*/ LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); linearLayout.setLayoutParams(params); ScrollView scrollView = new ScrollView(getActivity()); scrollView.setLayoutParams(params); linearLayout.addView(scrollView); TextView textView = new TextView(getActivity()); textView.setLayoutParams(params); int padding = getResources().getDimensionPixelOffset(R.dimen.padding); textView.setPadding(padding, padding, padding, padding); switch (mType) { case Constants.FRAGMENT_ABOUT: textView.setGravity(Gravity.CENTER); textView.setText(getContent()); getActivity().setTitle(R.string.settings_about); break; case Constants.FRAGMENT_LICENSE: textView.setGravity(Gravity.CENTER); textView.setText(getContent()); getActivity().setTitle(R.string.settings_license); break; case Constants.FRAGMENT_POLICY: textView.setGravity(Gravity.START); textView.setText(getContent()); getActivity().setTitle(R.string.settings_policy); break; } setHasOptionsMenu(true); scrollView.addView(textView); return linearLayout; }
From source file:com.ubergeek42.WeechatAndroid.utils.UntrustedCertificateDialog.java
@NonNull @Override/*from ww w . j a v a2 s .com*/ public Dialog onCreateDialog(Bundle savedInstanceState) { final int padding = (int) getResources().getDimension(R.dimen.dialog_padding_full); final ScrollView scrollView = new ScrollView(getContext()); final TextView textView = new AppCompatTextView(getContext()); textView.setText(Html.fromHtml(getCertificateDescription())); scrollView.addView(textView); return new AlertDialog.Builder(getContext()).setTitle(getString(R.string.ssl_cert_dialog_title)) .setView(scrollView, padding, padding / 2, padding, 0) .setPositiveButton(getString(R.string.ssl_cert_dialog_accept_button), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { SSLHandler.getInstance(getContext()).trustCertificate(certificate); ((WeechatActivity) getActivity()).connect(); } }) .setNegativeButton(getString(R.string.ssl_cert_dialog_reject_button), null).create(); }
From source file:com.alexive.graphicalutils.demo.CardsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //On a real project, you'd define the layout in an xml file this.mLinearLayout = new LinearLayout(this); this.mLinearLayout.setOrientation(LinearLayout.VERTICAL); ScrollView sv = new ScrollView(this); sv.addView(this.mLinearLayout); setContentView(sv);// ww w.ja va 2 s.c o m this.mCardBuilder = new CardBuilder(CardBuilder.CardType.FULL_WIDTH_IMAGE); this.params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); int sixteenDP = ViewUtils.convertDPtoPixels(this, 16); this.params.setMargins(sixteenDP, sixteenDP / 2, sixteenDP, sixteenDP / 2); Drawable cardImage = ContextCompat.getDrawable(this, R.drawable.lisbon); this.mCardBuilder.setTitle("Card title here").setSubTitle("subtitle here") .addSupplementalAction(new CardBuilder.CardAction("A1", 1)) .addSupplementalAction(new CardBuilder.CardAction("A2", 2)).addActionClickListener(this) .setText("Text here! - To create a card like this use the " + "FULL_WIDTH_IMAGE card type") .setImage(cardImage); addCardToLayout(); this.mCardBuilder.setType(CardBuilder.CardType.IMAGE_AS_BACKGROUND).useLightTheme(false) //This one supports dark theme only .setText("Text here. Use IMAGE_AS_BACKGROUND for a card like this one"); addCardToLayout(); this.mCardBuilder.setType(CardBuilder.CardType.IMAGE_FILLS_WITH_ACTIONS_ON_LEFT).useLightTheme(true) .setText("Text here. IMAGE_FILLS_WITH_ACTIONS_ON_LEFT. " + "Notice this one doesn't display text"); addCardToLayout(); this.mCardBuilder.setType(CardBuilder.CardType.IMAGE_NEXT_TO_TITLE) .setText("Notice the previous one (IMAGE_FILLS_WITH_ACTIONS_ON_LEFT) " + "doesn't show any text. This one's a IMAGE_NEXT_TO_TITLE sample"); addCardToLayout(); this.mCardBuilder.reset(); //This clears the builder, you'll have to set it up again this.mCardBuilder.setType(CardBuilder.CardType.IMAGE_FILLS_WITH_ACTIONS_ON_LEFT).setImage(cardImage) .addSupplementalAction(new CardBuilder.CardAction( ContextCompat.getDrawable(this, R.drawable.ic_favorite_black_24dp), 3)) .addSupplementalAction(new CardBuilder.CardAction( ContextCompat.getDrawable(this, R.drawable.ic_info_outline_black_24dp), 4)) .addActionClickListener(this); addCardToLayout(); this.mCardBuilder.setType(CardBuilder.CardType.FULL_WIDTH_IMAGE).setTitle("Look, icons!") .setText("You can use icons as actions instead of text (or mix both)") .addSupplementalAction(new CardBuilder.CardAction("A5", 5)); addCardToLayout(); this.mCardBuilder.setType(CardBuilder.CardType.NO_IMAGE).setTitle("<Title>") .setText("This is the simplest one: NO_IMAGE"); addCardToLayout(); }
From source file:com.slushpupie.deskclock.ChangelogDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); // Standard AlertDialog does not support HTML-style links. // So rebuild the ScrollView->TextView with the appropriate // settings and set the view directly. TextView tv = new TextView(getActivity()); tv.setPadding(5, 5, 5, 5);//from ww w .j a va2 s .c o m tv.setLinksClickable(true); tv.setMovementMethod(LinkMovementMethod.getInstance()); tv.setText(R.string.changeLog); tv.setTextAppearance(getActivity(), android.R.style.TextAppearance_Medium); ScrollView sv = new ScrollView(getActivity()); sv.setPadding(14, 2, 10, 12); sv.addView(tv); builder.setView(sv).setCancelable(false).setTitle(R.string.changeLogTitle).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { ((DeskClock) getActivity()).acknoledgeChangelog(); } }); return builder.create(); }
From source file:ch.jeda.platform.android.LogFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { this.textView = new TextView(this.getActivity()); this.textView.setLayoutParams( new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); this.scrollView = new ScrollView(this.getActivity()); this.scrollView.addView(this.textView); this.updateView(); return this.scrollView; }
From source file:com.maxleap.demo.clouddata.log.LogFragment.java
public View inflateViews() { mScrollView = new ScrollView(getActivity()); ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mScrollView.setLayoutParams(scrollParams); mLogView = new LogNodeView(getActivity()); ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams); logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; mLogView.setLayoutParams(logParams); mLogView.setClickable(true);/* w w w . j a v a2 s . c o m*/ mLogView.setFocusable(true); mLogView.setTypeface(Typeface.MONOSPACE); // Want to set padding as 16 dips, setPadding takes pixels. Hooray math! int paddingDips = 16; double scale = getResources().getDisplayMetrics().density; int paddingPixels = (int) ((paddingDips * (scale)) + .5); mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels); mLogView.setCompoundDrawablePadding(paddingPixels); mLogView.setGravity(Gravity.BOTTOM); mScrollView.setBackgroundColor(0XFF000000); mLogView.setTextColor(0XFF5394EC); mScrollView.addView(mLogView); return mScrollView; }
From source file:org.sufficientlysecure.keychain.ui.HelpHtmlFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mActivity = getActivity();/*from w w w . j a v a2 s.c o m*/ mHtmlFile = getArguments().getInt(ARG_HTML_FILE); ScrollView scroller = new ScrollView(mActivity); HtmlTextView text = new HtmlTextView(mActivity); // padding int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, mActivity.getResources().getDisplayMetrics()); text.setPadding(padding, padding, padding, 0); scroller.addView(text); // load html from raw resource (Parsing handled by HtmlTextView library) text.setHtmlFromRawResource(getActivity(), mHtmlFile, true); // no flickering when clicking textview for Android < 4 text.setTextColor(getResources().getColor(android.R.color.black)); return scroller; }
From source file:com.wlz.awarenesstest.LogFragment.java
public View inflateViews() { mScrollView = new ScrollView(getActivity()); ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mScrollView.setLayoutParams(scrollParams); mLogView = new LogView(getActivity()); ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams); logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; mLogView.setLayoutParams(logParams); mLogView.setClickable(true);/*w ww. j a v a 2 s . c om*/ mLogView.setFocusable(true); mLogView.setTypeface(Typeface.MONOSPACE); // Want to set padding as 16 dips, setPadding takes pixels. Hooray math! int paddingDips = 16; double scale = getResources().getDisplayMetrics().density; int paddingPixels = (int) ((paddingDips * (scale)) + .5); mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels); mLogView.setCompoundDrawablePadding(paddingPixels); mLogView.setGravity(Gravity.BOTTOM); mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_DeviceDefault_Medium); mScrollView.addView(mLogView); return mScrollView; }
From source file:com.connectsdk.smarthomesampler.dialog.AcknowledgementsFragmentDialog.java
@NonNull @Override//from w w w. j av a2s.c o m public Dialog onCreateDialog(Bundle savedInstanceState) { Context context = getActivity(); final TextView message = new TextView(context); message.setText(Html.fromHtml(context.getString(R.string.info_message))); message.setMovementMethod(LinkMovementMethod.getInstance()); int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 25, context.getResources().getDisplayMetrics()); message.setPadding(padding, 0, padding, 0); ScrollView scrollView = new ScrollView(context); scrollView.addView(message); return new AlertDialog.Builder(context).setTitle(R.string.info_title).setView(scrollView) .setCancelable(true).create(); }