Example usage for android.widget ScrollView ScrollView

List of usage examples for android.widget ScrollView ScrollView

Introduction

In this page you can find the example usage for android.widget ScrollView ScrollView.

Prototype

public ScrollView(Context context) 

Source Link

Usage

From source file:Main.java

public static Dialog confirm(String title, View view, Context context,
        DialogInterface.OnClickListener onConfirmListener) {
    Builder dialogBuilder = confirmBuilder(title, context, onConfirmListener).setView(view);

    if (view instanceof TextView) {
        ScrollView scrollView = new ScrollView(context);
        scrollView.addView(view);//from  w w  w .  java2s  .  c o  m
        dialogBuilder.setView(scrollView);
    }

    AlertDialog dialog = dialogBuilder.create();

    if (view instanceof EditText) {
        dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE
                | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    }

    dialog.show();
    return dialog;
}

From source file:cc.softwarefactory.lokki.android.fragments.HelpFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    TextView textView = new TextView(getActivity());
    textView.setPadding(15, 15, 15, 15);
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    ScrollView scroller = new ScrollView(getActivity());
    scroller.addView(textView);//from  ww w  . j  av  a2  s . co  m

    return scroller;
}

From source file:com.contralabs.inmap.fragments.LegalNoticesDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context context = getActivity();

    ScrollView scrollView = new ScrollView(context);
    // Set up the TextView
    final TextView message = new TextView(context);
    // We'll use a spannablestring to be able to make links clickable
    final SpannableString s = new SpannableString(
            GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(context));

    // Set some padding
    int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10,
            getResources().getDisplayMetrics());
    message.setPadding(padding, padding, padding, padding);
    // Set up the final string
    message.setText(s);//from   w  ww.  j  a  va2 s .  co m
    scrollView.addView(message);
    // Now linkify the text
    Linkify.addLinks(message, Linkify.ALL);
    Linkify.addLinks(message, Pattern.compile("@([A-Za-z0-9_-]+)"), "https://twitter.com/#!/");
    return new AlertDialog.Builder(getActivity()).setTitle(R.string.legal_notices).setCancelable(true)
            .setIcon(R.drawable.ic_launcher)
            .setPositiveButton(context.getString(R.string.voltar), (OnClickListener) null).setView(scrollView)
            .create();
}

From source file:org.solovyev.android.messenger.wizard.BaseWizardStep.java

@Nonnull
protected View inflateView(int layoutResId) {
    final View view = LayoutInflater.from(getActivity()).inflate(layoutResId, null);

    final ScrollView scrollView = new ScrollView(getActivity());
    scrollView.addView(view);/*from   w  w  w  .jav a 2  s. c  o  m*/
    return scrollView;
}

From source file:ar.rulosoft.mimanganu.LicenseFragment.java

@Nullable
@Override/*from   w  ww.  j a  va2  s . c  o  m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setHasOptionsMenu(true);
    setRetainInstance(true);
    mLicenseView = new TextView(getActivity());
    //        mLicenseView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Medium);
    mLicenseView.setPadding(10, 10, 10, 10);
    if (!MainActivity.darkTheme) {
        mLicenseView.setTextColor(ContextCompat.getColor(getContext(), black));
    }
    ScrollView newScroll = new ScrollView(getActivity());
    newScroll.addView(mLicenseView);
    return newScroll;
}

From source file:com.ryan.demostore.logger.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.setTextAppearance(android.R.style.TextAppearance_Material_Medium);
    mLogView.setLayoutParams(logParams);
    mLogView.setClickable(true);/*from  w  w  w  .ja v a 2  s  . c o  m*/
    mLogView.setFocusable(true);
    mLogView.setTypeface(Typeface.create("monospace", Typeface.NORMAL));

    // 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.addView(mLogView);
    return mScrollView;
}

From source file:com.example.song.myapplication.logger.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 com.example.song.myapplication.logger.LogView(getActivity());
    ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams);
    logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
    mLogView.setLayoutParams(logParams);
    mLogView.setClickable(true);//from   ww w .j  a  v  a  2s . co  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);
    mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium);

    mScrollView.addView(mLogView);
    return mScrollView;
}

From source file:org.telegram.ui.Components.BotKeyboardView.java

public BotKeyboardView(Context context) {
    super(context);

    setOrientation(VERTICAL);//  w  ww  .j  a v  a 2s .c o m

    ScrollView scrollView = new ScrollView(context);
    addView(scrollView);
    container = new LinearLayout(context);
    container.setOrientation(VERTICAL);
    scrollView.addView(container);

    setBackgroundColor(ContextCompat.getColor(context, R.color.sticker_select_background));
}

From source file:com.google.adsensequickstart.DisplayInventoryFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    ScrollView sv = new ScrollView(getActivity());
    TableLayout tl = new TableLayout(getActivity());
    tl.setBackgroundColor(Color.rgb(242, 239, 233));
    sv.addView(tl);/* w w w .j av a2s  .  co  m*/

    if (displayInventoryController == null) {
        return sv;
    }
    Inventory inventory = displayInventoryController.getInventory();

    TableLayout.LayoutParams tableRowParams = new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    tableRowParams.setMargins(1, 1, 1, 1);

    TableRow.LayoutParams accountLayoutParams = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    accountLayoutParams.setMargins(2, 1, 2, 1);

    TableRow.LayoutParams adCLientLayoutParams = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    adCLientLayoutParams.setMargins(12, 1, 2, 1);

    TableRow.LayoutParams adUnitChannelLayoutParams = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    adUnitChannelLayoutParams.setMargins(24, 1, 2, 1);

    for (String accountId : inventory.getAccounts()) {
        TableRow trow = new TableRow(getActivity());
        tl.addView(trow);
        TextView tv = new TextView(getActivity());
        tv.setText(accountId);
        trow.addView(tv);
        tv.setLayoutParams(accountLayoutParams);

        for (String adClient : inventory.getAdClients(accountId)) {
            TableRow trow2 = new TableRow(getActivity());
            trow2.setBackgroundColor(Color.rgb(214, 204, 181));
            tl.addView(trow2);
            TextView tv2 = new TextView(getActivity());
            tv2.setText(adClient);
            trow2.addView(tv2);
            tv2.setLayoutParams(adCLientLayoutParams);
            for (String adUnit : inventory.getAdUnits(adClient)) {
                TableRow trow3 = new TableRow(getActivity());
                trow3.setBackgroundColor(Color.rgb(251, 145, 57));
                tl.addView(trow3);
                TextView tv3 = new TextView(getActivity());
                tv3.setText(adUnit);
                trow3.addView(tv3);
                tv3.setLayoutParams(adUnitChannelLayoutParams);
            }
            for (String customChannel : inventory.getCustomChannels(adClient)) {
                TableRow trow3 = new TableRow(getActivity());
                trow3.setBackgroundColor(Color.rgb(255, 195, 69));
                tl.addView(trow3);
                TextView tv3 = new TextView(getActivity());
                tv3.setText(customChannel);
                trow3.addView(tv3);
                tv3.setLayoutParams(adUnitChannelLayoutParams);
            }
        }
    }
    return sv;
}

From source file:at.wada811.android.library.demos.SplashActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // catch UncaughtException
    Thread.setDefaultUncaughtExceptionHandler(new CrashExceptionHandler(getApplicationContext()));
    super.onCreate(savedInstanceState);
    // ???????//w w w . j av a2 s.c o  m
    File file = ResourceUtils.getFile(this, CrashExceptionHandler.FILE_NAME);
    if (file.exists()) {
        String report = ResourceUtils.readFileString(this, CrashExceptionHandler.FILE_NAME);
        ScrollView scrollView = new ScrollView(this);
        TextView textView = new TextView(this);
        textView.setText(report);
        scrollView.addView(textView);
        setContentView(scrollView);
        file.delete();
    } else {
        startActivity(new Intent(this, MainActivity.class));
        finish();
    }
}