List of usage examples for android.widget HorizontalScrollView post
public boolean post(Runnable action)
Causes the Runnable to be added to the message queue.
From source file:com.mobicage.rogerthat.plugins.friends.ServiceSearchActivity.java
private void displayTab(int tab) { final int childCount = mSearchCategoryViewFlipper.getChildCount(); if (childCount == 0) { return;//from w w w. j a v a 2 s . c o m } while (tab < 0) tab += childCount; tab = tab % childCount; mSearchCategoryViewFlipper.setDisplayedChild(tab); for (int i = 0; i < childCount; i++) { SearchInfo si = mSearchInfoByListView.get(mSearchCategoryViewFlipper.getChildAt(i)); if (si == null) { L.bug("Could not find list view!"); return; } final boolean selected = tab == i; final LinearLayout v = si.label; setCatorySelected(v, selected); if (selected) { final HorizontalScrollView sv = (HorizontalScrollView) findViewById( R.id.search_category_scroll_container); sv.post(new SafeRunnable() { @Override public void safeRun() { int vLeft = v.getLeft(); int vRight = v.getRight(); int width = v.getWidth(); sv.smoothScrollTo(((vLeft + vRight) / 2) - (width), 0); } }); } } }
From source file:org.catrobat.paintroid.ui.BottomBar.java
private void startBottomBarAnimation() { final HorizontalScrollView horizontalScrollView = (HorizontalScrollView) mMainActivity .findViewById(R.id.bottom_bar_scroll_view); final ScrollView verticalScrollView = (ScrollView) mMainActivity .findViewById(R.id.bottom_bar_landscape_scroll_view); final int animationDuration = 1000; int orientation = mMainActivity.getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_PORTRAIT) { horizontalScrollView.post(new Runnable() { public void run() { int scrollToX = (int) (getToolButtonByToolType(mCurrentToolType).getX() - horizontalScrollView.getWidth() / 2.0f + mMainActivity.getResources().getDimension(R.dimen.bottom_bar_button_width) / 2.0f); int scrollFromX = PaintroidApplication.isRTL ? horizontalScrollView.getChildAt(0).getLeft() : horizontalScrollView.getChildAt(0).getRight(); horizontalScrollView.setScrollX(scrollFromX); ObjectAnimator.ofInt(horizontalScrollView, "scrollX", scrollToX).setDuration(animationDuration) .start();//from w w w .ja va 2 s .c o m } }); } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) { verticalScrollView.post(new Runnable() { public void run() { int scrollToY = (int) (getToolButtonByToolType(mCurrentToolType).getY() - verticalScrollView.getHeight() / 2.0f + mMainActivity.getResources().getDimension(R.dimen.bottom_bar_landscape_button_height) / 2.0f); int scrollFromY = verticalScrollView.getChildAt(0).getBottom(); verticalScrollView.setScrollY(scrollFromY); ObjectAnimator.ofInt(verticalScrollView, "scrollY", scrollToY).setDuration(animationDuration) .start(); } }); } delayedAnimateSelectedTool(animationDuration); }
From source file:org.mythtv.client.ui.dvr.GuideTimeslotsFragment.java
private void scrollTimeslot() { final HorizontalScrollView hsv = (HorizontalScrollView) getActivity() .findViewById(R.id.program_guide_timeslots_scrollview); if (null != hsv) { hsv.post(new Runnable() { /* (non-Javadoc) * @see java.lang.Runnable#run() *//*w w w . j a v a 2 s. co m*/ @Override public void run() { final View child = ((LinearLayout) hsv.getChildAt(0)).getChildAt(startingTimeslot); Log.v(TAG, "onActivityCreated : scroll to timeslot(" + child.getWidth() + ") " + startingTimeslot + " at postion '" + (startingTimeslot * (child.getWidth())) + "'"); hsv.scrollTo((startingTimeslot * (child.getWidth())), 0); } }); } }
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 .j a va 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); } }); }