List of usage examples for android.widget HorizontalScrollView getWidth
@ViewDebug.ExportedProperty(category = "layout") public final int getWidth()
From source file:org.orange.querysystem.content.TabsAdapter.java
public void adjustSelectedTabToCenter() { View currentTab = mTabHost.getCurrentTabView(); if (currentTab == null) { return;/*from w ww . jav a 2 s . c o m*/ } HorizontalScrollView hsv = (HorizontalScrollView) mTabHost.findViewById(R.id.tabs_scroll); hsv.smoothScrollTo(currentTab.getLeft() + (currentTab.getWidth() - hsv.getWidth()) / 2, 0); }
From source file:org.catrobat.paintroid.ui.BottomBar.java
private void scrollToSelectedTool(ToolType toolType) { int orientation = mMainActivity.getResources().getConfiguration().orientation; View toolButton = getToolButtonByToolType(toolType); if (orientation == Configuration.ORIENTATION_PORTRAIT) { HorizontalScrollView scrollView = (HorizontalScrollView) mMainActivity .findViewById(R.id.bottom_bar_scroll_view); scrollView.smoothScrollTo(/*from w ww. j a va 2 s . c om*/ (int) (toolButton.getX() - scrollView.getWidth() / 2.0f + toolButton.getWidth() / 2.0f), (int) toolButton.getY()); } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) { ScrollView scrollView = (ScrollView) mMainActivity.findViewById(R.id.bottom_bar_landscape_scroll_view); scrollView.smoothScrollTo((int) (toolButton.getX()), (int) (toolButton.getY() - scrollView.getHeight() / 2.0f + toolButton.getHeight() / 2.0f)); } }
From source file:org.catrobat.paintroid.test.integration.BaseIntegrationTestClass.java
private void scrollToolBarToLeft() { HorizontalScrollView scrollView = (HorizontalScrollView) mSolo.getView(R.id.bottom_bar_scroll_view); int[] screenLocation = { 0, 0 }; scrollView.getLocationOnScreen(screenLocation); int getAwayFromNavigationDrawer = 60; float fromX = screenLocation[0] + getAwayFromNavigationDrawer; float toX = screenLocation[0] + scrollView.getWidth(); float yPos = screenLocation[1] + (scrollView.getHeight() / 2.0f); mSolo.drag(fromX, toX, yPos, yPos, 1); }
From source file:org.catrobat.paintroid.test.integration.BaseIntegrationTestClass.java
protected View scrollToToolButton(ToolType toolType) { HorizontalScrollView scrollView = (HorizontalScrollView) mSolo.getView(R.id.bottom_bar_scroll_view); int scrollRight = 1; int scrollLeft = -1; View toolButtonView = null;/*from www . jav a 2s. com*/ while (scrollView.canScrollHorizontally(scrollLeft)) { scrollToolBarToLeft(); } float scrollPosRight = scrollView.getX() + scrollView.getWidth(); int[] btnLocation = { 0, 0 }; getToolButtonView(toolType).getLocationOnScreen(btnLocation); float btnPos = btnLocation[0] + (getToolButtonView(toolType).getWidth() / 2.0f); if (btnPos < scrollPosRight) { toolButtonView = getToolButtonView(toolType); } while (scrollView.canScrollHorizontally(scrollRight) && toolButtonView == null) { mSolo.scrollViewToSide(scrollView, Solo.RIGHT); getToolButtonView(toolType).getLocationOnScreen(btnLocation); btnPos = btnLocation[0] + (getToolButtonView(toolType).getWidth() / 2.0f); if (btnPos < scrollPosRight) { toolButtonView = getToolButtonView(toolType); break; } } assertNotNull("Tool button not found", toolButtonView); return toolButtonView; }
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();/*www . j a v a 2 s .c om*/ } }); } 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:com.raspi.chatapp.ui.chatting.SendImageFragment.java
/** * changes the page.//from ww w. j a v a2 s. c om * * @param position the page to go to. * @param clicked if true, the viewPager is set to the position */ private void changePage(final int position, boolean clicked, boolean force) { if (images.size() > 1 && (force || current != position)) { Log.d("SEND_IMAGE", "page changed"); images.get(current).getBackground().setVisibility(View.GONE); images.get(position).getBackground().setVisibility(View.VISIBLE); current = position; // scroll to correct position HorizontalScrollView scrollView = (HorizontalScrollView) getActivity() .findViewById(R.id.send_image_overview); View view = images.get(current).getLayout(); int vLeft = view.getLeft(); int vRight = view.getRight(); int sWidth = scrollView.getWidth(); if (!isViewVisible(scrollView, view)) scrollView.smoothScrollTo((vLeft + vRight - sWidth) / 2, 0); if (clicked) // setting the viewPagers item is posted via a handler, so the gui // thread finishes the scrollView related task before switching the // viewPager. That way it seems smoother because the new image is // selected instantly. new Handler().post(new Runnable() { @Override public void run() { viewPager.setCurrentItem(position); } }); } }
From source file:org.egov.android.view.activity.CreateComplaintActivity.java
/** * Function used to show the image added to complaint in image view. A close icon is shown at * the top right corner of the image to delete it * /* w w w.j a va 2s.c o m*/ * @param imagePath */ @SuppressLint("InflateParams") private void _addImageView(String imagePath) { final ImageView image_container = (ImageView) findViewById(R.id.image_container); LinearLayout container = (LinearLayout) findViewById(R.id.container); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.add_photo, null); RelativeLayout inner_container = (RelativeLayout) view.findViewById(R.id.inner_container); LinearLayout.LayoutParams inner_container_params = new LinearLayout.LayoutParams(_dpToPix(100), _dpToPix(100)); inner_container.setLayoutParams(inner_container_params); ImageView image = (ImageView) view.findViewById(R.id.image); image.setImageBitmap(_getBitmapImage(imagePath)); image.setTag(imagePath); container.addView(inner_container); imageUrl.add(imagePath); image_container.setImageBitmap(_getBitmapImage(imagePath)); ImageView delete_icon = (ImageView) view.findViewById(R.id.delete_photo); delete_icon.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { file_upload_limit--; RelativeLayout deleteView = (RelativeLayout) v.getParent(); ((LinearLayout) findViewById(R.id.container)).removeView(deleteView); ImageView image = (ImageView) deleteView.findViewById(R.id.image); _deleteFile(image.getTag().toString()); _reorderFiles(); } }); inner_container.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ImageView image = (ImageView) v.findViewById(R.id.image); ((ImageView) findViewById(R.id.image_container)) .setImageBitmap(_getBitmapImage(image.getTag().toString())); } }); Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { HorizontalScrollView hsv = (HorizontalScrollView) findViewById(R.id.hr_scroll); hsv.scrollTo(hsv.getWidth() + 600, 0); } }, 500); }