android.widget.HorizontalScrollView.post()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(10.3k)|赞(0)|评价(0)|浏览(165)

本文整理了Java中android.widget.HorizontalScrollView.post()方法的一些代码示例,展示了HorizontalScrollView.post()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HorizontalScrollView.post()方法的具体详情如下:
包路径:android.widget.HorizontalScrollView
类名称:HorizontalScrollView
方法名:post

HorizontalScrollView.post介绍

暂无

代码示例

代码示例来源:origin: jiangqqlmj/FastDev4Android

@Override
public void onPageSelected(int position) {
  //首先设置当前的Item为正常状态
  View preView=mClassContainer.getChildAt(mCurClassIndex);
  ((TextView)(preView.findViewById(R.id.horizontal_tv_type))).setTextColor(mColorUnSelected);
  ((ImageView)(preView.findViewById(R.id.horizontal_img_type))).setImageResource(R.drawable.bottom_line_gray);
  mCurClassIndex=position;
  //设置当前为选中状态
  View currentItem=mClassContainer.getChildAt(mCurClassIndex);
  ((ImageView)(currentItem.findViewById(R.id.horizontal_img_type))).setImageResource(R.drawable.bottom_line_blue);
  ((TextView)(currentItem.findViewById(R.id.horizontal_tv_type))).setTextColor(mColorSelected);
  //这边移动的距离 是经过计算粗略得出来的
  mScrollX=currentItem.getLeft()-300;
  Log.d("zttjiangqq", "mScrollX:" + mScrollX);
  mScrollBar.post(new Runnable() {
    @Override
    public void run() {
      mScrollBar.scrollTo(mScrollX,0);
    }
  });
}

代码示例来源:origin: jiangqqlmj/FastDev4Android

private void initValidata(){
  mColorSelected= FDApplication.getInstance().getResources().getColor(R.color.color_selected);
  mColorUnSelected=FDApplication.getInstance().getResources().getColor(R.color.color_unselected);
  //添加Tab标签
  addScrollView(titles);
  mScrollBar.post(new Runnable() {
    @Override
    public void run() {
      mScrollBar.scrollTo(mScrollX, 0);
    }
  });
  fragments=new ArrayList<>();
  for(int i=0;i<12;i++){
    OneFragment oneFragment=new OneFragment();
    Bundle bundle=new Bundle();
    bundle.putString("extra",titles[i]);
    oneFragment.setArguments(bundle);
    fragments.add(oneFragment);
  }
  mPagerAdater=new CNKFixedPagerAdapter(getChildFragmentManager());
  mPagerAdater.setTitles(titles);
  mPagerAdater.setFragments(fragments);
  info_viewpager.setAdapter(mPagerAdater);
  info_viewpager.setOnPageChangeListener(this);
}
/**

代码示例来源:origin: WuXiaolong/WoChat

private void scrollTo(final int position){
  int childCount = tabContainer.getChildCount();
  if(position < childCount){
    scrollView.post(new Runnable() {
      @Override
      public void run() {
        int mScrollX = tabContainer.getScrollX();
        int childX = (int)ViewCompat.getX(tabContainer.getChildAt(position));
        if(childX < mScrollX){
          scrollView.scrollTo(childX,0);
          return;
        }
        int childWidth = (int)tabContainer.getChildAt(position).getWidth();
        int hsvWidth = scrollView.getWidth();
        int childRight = childX + childWidth;
        int scrollRight = mScrollX + hsvWidth;
        if(childRight > scrollRight){
          scrollView.scrollTo(childRight - scrollRight,0);
          return;
        }
      }
    });
  }
}

代码示例来源:origin: easemob/kefu-android-demo

private void scrollTo(final int position){
  int childCount = tabContainer.getChildCount();
  if(position < childCount){
    scrollView.post(new Runnable() {
      @Override
      public void run() {
        int mScrollX = tabContainer.getScrollX();
        int childX = (int)ViewCompat.getX(tabContainer.getChildAt(position));
        if(childX < mScrollX){
          scrollView.scrollTo(childX,0);
          return;
        }
        int childWidth = tabContainer.getChildAt(position).getWidth();
        int hsvWidth = scrollView.getWidth();
        int childRight = childX + childWidth;
        int scrollRight = mScrollX + hsvWidth;
        if(childRight > scrollRight){
          scrollView.scrollTo(childRight - scrollRight,0);
        }
      }
    });
  }
}

代码示例来源:origin: huangfangyi/FanXin

private void scrollTo(final int position){
  int childCount = tabContainer.getChildCount();
  if(position < childCount){
    scrollView.post(new Runnable() {
      @Override
      public void run() {
        int mScrollX = tabContainer.getScrollX();
        int childX = (int)ViewCompat.getX(tabContainer.getChildAt(position));
        if(childX < mScrollX){
          scrollView.scrollTo(childX,0);
          return;
        }
        int childWidth = (int)tabContainer.getChildAt(position).getWidth();
        int hsvWidth = scrollView.getWidth();
        int childRight = childX + childWidth;
        int scrollRight = mScrollX + hsvWidth;
        if(childRight > scrollRight){
          scrollView.scrollTo(childRight - scrollRight,0);
          return;
        }
      }
    });
  }
}

代码示例来源:origin: easemob/livestream_demo_android

private void scrollTo(final int position){
  int childCount = tabContainer.getChildCount();
  if(position < childCount){
    scrollView.post(new Runnable() {
      @Override
      public void run() {
        int mScrollX = tabContainer.getScrollX();
        int childX = (int)ViewCompat.getX(tabContainer.getChildAt(position));
        if(childX < mScrollX){
          scrollView.scrollTo(childX,0);
          return;
        }
        int childWidth = (int)tabContainer.getChildAt(position).getWidth();
        int hsvWidth = scrollView.getWidth();
        int childRight = childX + childWidth;
        int scrollRight = mScrollX + hsvWidth;
        if(childRight > scrollRight){
          scrollView.scrollTo(childRight - scrollRight,0);
          return;
        }
      }
    });
  }
}

代码示例来源:origin: lzan13/EaseUICustomer

private void scrollTo(final int position){
  int childCount = tabContainer.getChildCount();
  if(position < childCount){
    scrollView.post(new Runnable() {
      @Override
      public void run() {
        int mScrollX = tabContainer.getScrollX();
        int childX = (int)ViewCompat.getX(tabContainer.getChildAt(position));
        if(childX < mScrollX){
          scrollView.scrollTo(childX,0);
          return;
        }
        int childWidth = (int)tabContainer.getChildAt(position).getWidth();
        int hsvWidth = scrollView.getWidth();
        int childRight = childX + childWidth;
        int scrollRight = mScrollX + hsvWidth;
        if(childRight > scrollRight){
          scrollView.scrollTo(childRight - scrollRight,0);
          return;
        }
      }
    });
  }
}

代码示例来源:origin: stevenwsg/XSY-University-trade

private void scrollTo(final int position){
  int childCount = tabContainer.getChildCount();
  if(position < childCount){
    scrollView.post(new Runnable() {
      @Override
      public void run() {
        int mScrollX = tabContainer.getScrollX();
        int childX = (int)ViewCompat.getX(tabContainer.getChildAt(position));
        if(childX < mScrollX){
          scrollView.scrollTo(childX,0);
          return;
        }
        int childWidth = (int)tabContainer.getChildAt(position).getWidth();
        int hsvWidth = scrollView.getWidth();
        int childRight = childX + childWidth;
        int scrollRight = mScrollX + hsvWidth;
        if(childRight > scrollRight){
          scrollView.scrollTo(childRight - scrollRight,0);
          return;
        }
      }
    });
  }
}

代码示例来源:origin: sunhapper/SpEditTool

private void scrollTo(final int position) {
 int childCount = tabContainer.getChildCount();
 if (position < childCount) {
  scrollView.post(new Runnable() {
   @Override
   public void run() {
    int mScrollX = tabContainer.getScrollX();
    int childX = (int)tabContainer.getChildAt(position).getX();
    if (childX < mScrollX) {
     scrollView.scrollTo(childX, 0);
     return;
    }
    int childWidth = tabContainer.getChildAt(position).getWidth();
    int hsvWidth = scrollView.getWidth();
    int childRight = childX + childWidth;
    int scrollRight = mScrollX + hsvWidth;
    if (childRight > scrollRight) {
     scrollView.scrollTo(childRight - scrollRight, 0);
     return;
    }
   }
  });
 }
}

代码示例来源:origin: Vegen/SmartCampus

private void scrollTo(final int position){
  int childCount = tabContainer.getChildCount();
  if(position < childCount){
    scrollView.post(new Runnable() {
      @Override
      public void run() {
        int mScrollX = tabContainer.getScrollX();
        int childX = (int)ViewCompat.getX(tabContainer.getChildAt(position));
        if(childX < mScrollX){
          scrollView.scrollTo(childX,0);
          return;
        }
        int childWidth = (int)tabContainer.getChildAt(position).getWidth();
        int hsvWidth = scrollView.getWidth();
        int childRight = childX + childWidth;
        int scrollRight = mScrollX + hsvWidth;
        if(childRight > scrollRight){
          scrollView.scrollTo(childRight - scrollRight,0);
          return;
        }
      }
    });
  }
}

代码示例来源:origin: zhangchunbin/HuanXinDemo

private void scrollTo(final int position){
  int childCount = tabContainer.getChildCount();
  if(position < childCount){
    scrollView.post(new Runnable() {
      @Override
      public void run() {
        int mScrollX = tabContainer.getScrollX();
        int childX = (int)ViewCompat.getX(tabContainer.getChildAt(position));
        if(childX < mScrollX){
          scrollView.scrollTo(childX,0);
          return;
        }
        int childWidth = (int)tabContainer.getChildAt(position).getWidth();
        int hsvWidth = scrollView.getWidth();
        int childRight = childX + childWidth;
        int scrollRight = mScrollX + hsvWidth;
        if(childRight > scrollRight){
          scrollView.scrollTo(childRight - scrollRight,0);
          return;
        }
      }
    });
  }
}

代码示例来源:origin: Calsign/APDE

@Override
      public void run() {
        // Scroll to the bottom
        scroll.fullScroll(ScrollView.FOCUS_DOWN);
        
        scrollX.post(new Runnable() {
          public void run() {
            // Don't scroll horizontally at all...
            // TODO This doesn't really work
            scrollX.scrollTo(0, 0);
          }
        });
    }});
}

代码示例来源:origin: jakebonk/BoardView

public void scrollToColumn(int column,boolean animate){
  if(column >= 0) {
    View childView = mParentLayout.getChildAt(column);
    if(childView != null) {
      final int newX = childView.getLeft() - (int) (((getMeasuredWidth() - childView.getMeasuredWidth()) / 2));
      if (animate) {
        mRootLayout.post(new Runnable() {
          @Override
          public void run() {
            mRootLayout.smoothScrollTo(newX, 0);
          }
        });
      } else {
        mRootLayout.scrollTo(newX, 0);
      }
    }
  }
}

代码示例来源:origin: stackoverflow.com

public void scroll(int scroll_to)
{
  final int x = scroll_to;
  final HorizontalScrollView scrl = (HorizontalScrollView)findViewById(R.id.horizontalScrollView1);
  scrl.post(new Runnable()
  {
    public void run()
    {
      scrl.scrollTo(0, x);
    } 
  });
}

代码示例来源:origin: stackoverflow.com

@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Some code such as layout inflation.

    final HorizontalScrollView hsv = (HorizontalScrollView) findViewById(R.id.ScrollView);

    // Scrolling to button 5.
    hsv.post(new Runnable() {
      @Override
      public void run() {
        // Get the button.
        View button = findViewById(R.id.btn5);

        // Locate the button.
        int x, y;
        x = button.getLeft();
        y = button.getTop();

        // Scroll to the button.
        hsv.scrollTo(x, y);
      }
    });
  }
}

代码示例来源:origin: stackoverflow.com

scroll.post(new Runnable() {
  public void run() {
    scroll.fullScroll(ScrollView.FOCUS_RIGHT);

代码示例来源:origin: MyScript/interactive-ink-examples-android

scrollView.post(new Runnable()

代码示例来源:origin: stackoverflow.com

mScrollView.post(new Runnable() {
  public void run() {
    tv1.setHorizontallyScrolling(true);

代码示例来源:origin: stackoverflow.com

private EditText mEditText;
private HorizontalScrollView mScrollView;

private void init() {
  mEditText = (EditText) findViewById(R.id.TEXT_STATUS_ID);
  mScrollView = (HorizontalScrollView) findViewById(R.id.SCROLLER_ID);
  // loadDoc();
  String s = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
      + "Aliquam tempus convallis metus, ac congue dui elementum ut."
      + "Suspendisse rutrum non sapien feugiat fermentum."
      + "Phasellus vulputate quam in sapien vulputate venenatis."
      + "Pellentesque porta tincidunt nisi, et scelerisque augue facilisis nec."
      + "Curabitur eget risus quam."
      + "Maecenas pellentesque egestas enim, in ornare nisl lobortis id."
      + "Nunc vitae facilisis libero, vitae porttitor tellus.";
  mEditText.setText(s);
  scrollToBottom();
}

private void scrollToBottom() {
  mScrollView.post(new Runnable() {
    public void run() {
      mEditText.setHorizontallyScrolling(true);
      mEditText.setMovementMethod(new ScrollingMovementMethod());
      mScrollView.smoothScrollTo(0, mEditText.getBottom());
    }
  });
}

代码示例来源:origin: Calsign/APDE

scrollerX.post(new Runnable() {
  public void run() {
    scrollerX.scrollTo(getScrollX(), 0);

相关文章

HorizontalScrollView类方法