当前位置: 首页>>代码示例>>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;未经允许,请勿转载。