當前位置: 首頁>>代碼示例>>Java>>正文


Java HorizontalScrollView.getWidth方法代碼示例

本文整理匯總了Java中android.widget.HorizontalScrollView.getWidth方法的典型用法代碼示例。如果您正苦於以下問題:Java HorizontalScrollView.getWidth方法的具體用法?Java HorizontalScrollView.getWidth怎麽用?Java HorizontalScrollView.getWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.HorizontalScrollView的用法示例。


在下文中一共展示了HorizontalScrollView.getWidth方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: hscrollOnDrag

import android.widget.HorizontalScrollView; //導入方法依賴的package包/類
private void hscrollOnDrag(View view, DragEvent event, HorizontalScrollView scrollView) {
    float tx = view.getLeft() + event.getX();

    if (isAncestor(scrollView, view)) {

        int thresh = scrollView.getWidth() / 6;

        if (tx < scrollView.getScrollX() + thresh) {
            scrollView.smoothScrollBy(-10, 0);
        } else if (tx > scrollView.getScrollX() + scrollView.getWidth() - thresh) {
            scrollView.smoothScrollBy(10,0);
        }
    }
}
 
開發者ID:quaap,項目名稱:LaunchTime,代碼行數:15,代碼來源:MainActivity.java

示例2: changePage

import android.widget.HorizontalScrollView; //導入方法依賴的package包/類
/**
 * changes the page.
 *
 * @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);
        }
      });
  }
}
 
開發者ID:Nik-Sch,項目名稱:ChatApp-Android,代碼行數:35,代碼來源:SendImageFragment.java

示例3: onTabChanged

import android.widget.HorizontalScrollView; //導入方法依賴的package包/類
public void onTabChanged(String tabId){
    int selectedItem = tabHost.getCurrentTab();
    viewPager.setCurrentItem(selectedItem);
    //View rootView= inflater.inflate(R.layout.fragment_first_aid, container, false);
    HorizontalScrollView hScrollView = (HorizontalScrollView) rootView.findViewById(R.id.h_scroll_view);
    View tabView = tabHost.getCurrentTabView();
    int scrollPos = tabView.getLeft()-(hScrollView.getWidth()-tabView.getWidth())/2;
    hScrollView.smoothScrollTo(scrollPos,0);
    //32.28
}
 
開發者ID:DamianPilot382,項目名稱:Health-App,代碼行數:11,代碼來源:FirstAidFragment.java


注:本文中的android.widget.HorizontalScrollView.getWidth方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。