Android ScrollView - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ScrollView class.

This code example shows how to use the following methods:addView, setOrientation, addView
    @Override 
    public void onCreate(Bundle savedInstanceState) 
    { 
        super.onCreate(savedInstanceState);
 
        LinearLayout layout = new LinearLayout(this);
        layout.setOrientation(LinearLayout.VERTICAL);
        mRootView = new ScrollView(this);
         
        EditText editText = new EditText(this);
        editText.requestFocus();
        mDefaultFocusedView = editText;
        layout.addView(editText);
 
        ((ScrollView) mRootView).addView(layout);
        setContentView(mRootView);
         
        // set to resize so IME is always shown (and also so 
        // ImfBaseTestCase#destructiveCheckImeInitialState thinks it should always be shown 
        this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
9
CodeRank
This code example shows how to use the following methods:addView, setOrientation, addView
9
CodeRank
This code example shows how to use the following methods:setBackgroundColor, setLayoutParams, setScrollContainer, addView, setFillViewport
7
CodeRank
This code example shows how to use the following methods:setLayoutParams, setVerticalScrollBarEnabled, addView
        LinearLayout layout = new LinearLayout(context);
        layout.setOrientation(LinearLayout.VERTICAL);
        layout.setPadding(6, 6, 6, 6);
 
        // Create a ScrollView to put the text in. Shouldn't be necessary... 
        ScrollView tscroll = new ScrollView(context);
        tscroll.setVerticalScrollBarEnabled(true);
        tscroll.setLayoutParams(new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT, 1));
        layout.addView(tscroll);
 
        // Now create the text view and add it to the scroller. 
        textView = new TextView(context);
        textView.setTextSize(16);
        textView.setTextColor(0xffffffff);
        textView.setText(textId);
        textView.setLayoutParams(new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.FILL_PARENT,
                LinearLayout.LayoutParams.FILL_PARENT));

7
CodeRank
This code example shows how to use the following methods:setLayoutParams, addView, setFillViewport
				actionLayoutView = container.getBean("actionDetailLayoutView", bundleKeys);
				 
				LayoutParams scrollViewLayout = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,LinearLayout.LayoutParams.FILL_PARENT);
				LayoutParams childViewLayout = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,LinearLayout.LayoutParams.FILL_PARENT);
				 
				ScrollView scrollView = new ScrollView(getContext());
				scrollView.setFillViewport(true);
				scrollView.setLayoutParams(scrollViewLayout);
				scrollView.addView(actionLayoutView, childViewLayout);	
				 
				LinearLayout layout = new LinearLayout(getContext());
				LayoutParams masterParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,LinearLayout.LayoutParams.FILL_PARENT);
				 
				layout.setLayoutParams(masterParams);
				layout.setBackgroundDrawable(((Drawables)container.getBean("drawables")).getDrawable("slate.png", true, true, true));
				 
				layout.addView(scrollView);
				 
				view = layout;
			} 
7
CodeRank
This code example shows how to use the following methods:assertHasScreenCoordinates, assertOffScreenBelow, assertOnScreen, getHeight, getVerticalFadingEdgeLength
 
    @MediumTest 
    public void testScrollToOffScreenRectangleFromTop() { 
        // view is off screen 
        assertTrue(mClickToScrollFromAbove.hasFocus());
        ViewAsserts.assertOffScreenBelow(mScrollView, mChildToScrollTo);
 
        // click 
        sendKeys(KeyEvent.KEYCODE_DPAD_CENTER);
        getInstrumentation().waitForIdleSync();  // wait for scrolling to finish
 
        // should be on screen, positioned at the bottom (with room for 
        // fading edge) 
        ViewAsserts.assertOnScreen(mScrollView, mChildToScrollTo);
        ViewAsserts.assertHasScreenCoordinates(
                mScrollView, mChildToScrollTo,
                0, 
                mScrollView.getHeight()
                        - mChildToScrollTo.getHeight()
                        - mScrollView.getVerticalFadingEdgeLength());

7
CodeRank
This code example shows how to use the following methods:addView
 
        setContentView(scrollWrap(root));
    } 
 
    private View scrollWrap(View view) {
        ScrollView scroller = new ScrollView(this);
        scroller.addView(view, new ScrollView.LayoutParams(ScrollView.LayoutParams.MATCH_PARENT,
                ScrollView.LayoutParams.MATCH_PARENT));
        return scroller;
    } 
 
    private void addLabelToRoot(LinearLayout root, String text) {
        TextView label = new TextView(this);
        label.setText(text);
        root.addView(label, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
    } 
 
    private void addChildToRoot(LinearLayout root, LinearLayout layout) {
        root.addView(layout, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
7
CodeRank
This code example shows how to use the following methods:setPadding, addView, setView
	  return new AlertDialog.Builder(context)
	   .setTitle(title)
	   .setCancelable(true)
	   .setIcon(android.R.drawable.ic_dialog_info)
	   .setPositiveButton(button, null)
	   .setView(LinkifyText(context, text))
	   .create();
	 } 
 
		public static ScrollView LinkifyText(Context context, String message) 
		{ 
		    ScrollView svMessage = new ScrollView(context); 
		    TextView tvMessage = new TextView(context);
		 
		    SpannableString spanText = new SpannableString(message);
		 
		    Linkify.addLinks(spanText, Linkify.ALL);
		    tvMessage.setText(spanText);
		    tvMessage.setMovementMethod(LinkMovementMethod.getInstance());
		     

7
CodeRank
This code example shows how to use the following methods:addView
 
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        ScrollView sv = new ScrollView(this);
        ViewGroup.LayoutParams svLp = new ScrollView.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
 
        LinearLayout ll = new LinearLayout(this);
        ll.setLayoutParams(svLp);
        sv.addView(ll);
 
        InternalSelectionView isv = new InternalSelectionView(this, 10);
        int screenHeight = getWindowManager().getDefaultDisplay().getHeight();
        LinearLayout.LayoutParams llLp = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                2 * screenHeight);  // 2x screen height to ensure scrolling
        isv.setLayoutParams(llLp);
7
CodeRank
This code example shows how to use the following methods:setId, setLayoutParams, setScrollBarStyle, addView
        // To fight color branding. 
        ((Activity)getContext()).getWindow().setFormat(PixelFormat.RGBA_8888);
 
        // Create the scrollview over the dialog 
        final int dlgMarging = (int)convertDpToPixel(DEFAULT_MARGIN_DP);
        ScrollView sv = new ScrollView(getContext());
        sv.setId(generateViewId());
        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
                android.view.ViewGroup.LayoutParams.MATCH_PARENT,
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
        lp.setMargins(dlgMarging, 0, dlgMarging, 0);
        sv.setLayoutParams(lp);
        sv.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_INSET);
 
        // Now the vertical layout 
        LinearLayout ll = new LinearLayout(getContext());
        ll.setId(generateViewId());
        lp = new RelativeLayout.LayoutParams(
                android.view.ViewGroup.LayoutParams.MATCH_PARENT,
                android.view.ViewGroup.LayoutParams.MATCH_PARENT);

7
CodeRank

Related Android ScrollView Questions & Answers:

See Code Examples for Android ScrollView Methods: