Example usage for android.widget HorizontalScrollView fullScroll

List of usage examples for android.widget HorizontalScrollView fullScroll

Introduction

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

Prototype

public boolean fullScroll(int direction) 

Source Link

Document

Handles scrolling in response to a "home/end" shortcut press.

Usage

From source file:com.android.talkback.controller.CursorControllerAppTest.java

@MediumTest
public void testPrevious_horizontal() {
    setContentView(R.layout.cursor_horizontal_test);

    // Scroll to the very right to reach the last items before beginning test.
    getInstrumentation().runOnMainSync(new Runnable() {
        @Override//from  ww  w  .  ja  va 2  s  .  c o m
        public void run() {
            HorizontalScrollView scroller = (HorizontalScrollView) getViewForId(R.id.horiz_scroller);
            scroller.fullScroll(View.FOCUS_RIGHT);
        }
    });
    getInstrumentation().waitForIdleSync();
    waitForAccessibilityIdleSync();

    AccessibilityNodeInfoCompat firstLabel = getNodeForId(R.id.text_first_item);
    AccessibilityNodeInfoCompat lastLabel = getNodeForId(R.id.text_last_item);
    AccessibilityNodeInfoCompat horizScroller = getNodeForId(R.id.horiz_scroller);

    mCursorController.setCursor(lastLabel);
    waitForAccessibilityIdleSync();

    // This is the expected traversal:
    // (Initial focus) text_last_item
    // 1-7. horiz_scroller - all items
    // 8. text_first_item
    final int traversals = 8;
    List<AccessibilityNodeInfoCompat> nodes = navigate(TraversalStrategy.SEARCH_FOCUS_BACKWARD, traversals,
            true, true, true);

    assertHasParent(horizScroller, nodes.subList(0, traversals - 1));
    assertEquals(firstLabel, nodes.get(traversals - 1));
}

From source file:com.mobicage.rogerthat.plugins.messaging.ServiceMessageDetailActivity.java

private void addButton(final String senderName, String myEmail, boolean somebodyAnswered, boolean canEdit,
        TableLayout tableLayout, final ButtonTO button) {
    TableRow row = new TableRow(this);
    tableLayout.addView(row);//ww w  .ja v a 2 s .c om
    row.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT,
            TableLayout.LayoutParams.WRAP_CONTENT, 1));

    // XXX: inconsistent margin between 2 rows

    final Button buttonView = new Button(this);
    buttonView.setMinWidth(UIUtils.convertDipToPixels(this, 100));
    buttonView.setText(button.caption);
    buttonView.setTextColor(getResources().getColor(android.R.color.primary_text_dark));
    if (somebodyAnswered)
        buttonView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
    else {
        buttonView.setWidth(mDisplayWidth - UIUtils.convertDipToPixels(this, 12));
    }
    buttonView.setTextSize(19);
    row.addView(buttonView);

    final LinearLayout container = (LinearLayout) getLayoutInflater().inflate(R.layout.message_button_detail,
            null);
    container.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);

    boolean buttonSelectedByMe = false;
    for (MemberStatusTO status : mCurrentMessage.members) {
        if ((status.status & MessagingPlugin.STATUS_ACKED) == MessagingPlugin.STATUS_ACKED
                && ((button.id == null && status.button_id == null)
                        || (button.id != null && button.id.equals(status.button_id)))) {

            getLayoutInflater().inflate(R.layout.avatar, container);
            ImageView avatar = (ImageView) container.getChildAt(container.getChildCount() - 1);

            setAvatar(avatar, status.member);
            if (status.member.equals(myEmail))
                buttonSelectedByMe = true;

            int dp42 = UIUtils.convertDipToPixels(this, 42);
            int dp2 = UIUtils.convertDipToPixels(this, 1);
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) avatar.getLayoutParams();
            lp.setMargins(0, dp2, 0, 0);
            lp.width = dp42;
            lp.height = dp42;
        }
    }

    row.addView(container);

    boolean hasAction = button.action != null && !"".equals(button.action);
    final boolean buttonIsEnabled = canEdit
            && (mCurrentMessage.form != null || !buttonSelectedByMe || hasAction);
    buttonView.setEnabled(buttonIsEnabled);

    int color;
    if (button.id == null || mCurrentMessage.form != null && Message.POSITIVE.equals(button.id)) {
        color = buttonIsEnabled ? Message.GREEN_BUTTON_COLOR : Message.GREENGRAY_BUTTON_COLOR;
    } else if (mCurrentMessage.form != null && Message.NEGATIVE.equals(button.id)) {
        color = buttonIsEnabled ? Message.RED_BUTTON_COLOR : Message.REDGRAY_BUTTON_COLOR;
    } else {
        color = buttonIsEnabled ? Message.BLUE_BUTTON_COLOR : Message.BLUEGRAY_BUTTON_COLOR;
    }
    buttonView.getBackground().setColorFilter(color, PorterDuff.Mode.MULTIPLY);

    buttonView.setOnClickListener(new SafeViewOnClickListener() {

        @Override
        public void safeOnClick(View v) {
            T.UI();
            executeButtonClick(button, container, true);
        }
    });

    final HorizontalScrollView scroller = (HorizontalScrollView) findViewById(R.id.button_scroller);
    scroller.post(new SafeRunnable() {
        @Override
        protected void safeRun() throws Exception {
            scroller.fullScroll(ScrollView.FOCUS_RIGHT);
        }
    });
}

From source file:com.filemanager.free.activities.MainActivity.java

void sendScroll(final HorizontalScrollView scrollView) {
    final Handler handler = new Handler();
    new Thread(new Runnable() {
        @Override// w w w. j  av  a2  s.  co m
        public void run() {
            try {
                Thread.sleep(100);
            } catch (InterruptedException ignored) {
            }
            handler.post(new Runnable() {
                @Override
                public void run() {
                    scrollView.fullScroll(View.FOCUS_RIGHT);
                }
            });
        }
    }).start();
}

From source file:com.amaze.carbonfilemanager.activities.MainActivity.java

void sendScroll(final HorizontalScrollView scrollView) {
    final Handler handler = new Handler();
    new Thread(new Runnable() {
        @Override//from w ww .j a  v  a  2s  . c o m
        public void run() {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
            }
            handler.post(new Runnable() {
                @Override
                public void run() {
                    scrollView.fullScroll(View.FOCUS_RIGHT);
                }
            });
        }
    }).start();
}