本文整理汇总了Java中android.widget.ScrollView.smoothScrollTo方法的典型用法代码示例。如果您正苦于以下问题:Java ScrollView.smoothScrollTo方法的具体用法?Java ScrollView.smoothScrollTo怎么用?Java ScrollView.smoothScrollTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.ScrollView
的用法示例。
在下文中一共展示了ScrollView.smoothScrollTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: slowSmoothScrollTo
import android.widget.ScrollView; //导入方法依赖的package包/类
/** slower than smoothScrollTo */
private void slowSmoothScrollTo(final ScrollView parentScrollView, int scrollY, int autoScrollAnimationTime) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
ValueAnimator realSmoothScrollAnimation =
ValueAnimator.ofInt(parentScrollView.getScrollY(), scrollY);
realSmoothScrollAnimation.setDuration(autoScrollAnimationTime);
realSmoothScrollAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int scrollTo = (Integer) animation.getAnimatedValue();
parentScrollView.scrollTo(0, scrollTo);
}
});
realSmoothScrollAnimation.start();
} else {
parentScrollView.smoothScrollTo(0, scrollY);
}
}
示例2: onCreateView
import android.widget.ScrollView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_buy_ticket_info, null);
lvInfos = (ListView) v.findViewById(R.id.buyTicketInfo_lvInfos);
MyDatabase myDB = new MyDatabase(this.getActivity());
mAdapter= new SimpleAdapter(this.getActivity(), mLstDatas, R.layout.item_buy_ticket_info,
new String[]{MyDatabase.KEY, MyDatabase.VALUE},
new int[]{R.id.item_buy_ticket_info_tvQuestion, R.id.item_buy_ticket_info_tvAnswer}
);
lvInfos.setAdapter(mAdapter);
myDB.closeDB();
notifyAdapterDataChanged(myDB.getTicketInfos(0));
MyUtils.setListViewHeightBasedOnChildren(lvInfos); //设置ListView全部显示
ViewGroup.LayoutParams params = lvInfos.getLayoutParams();
params.height += 3000; //方法不太准,人为校正高度
lvInfos.setLayoutParams(params);
sv1 = (ScrollView)v.findViewById(R.id.buyTicketInfo_sv1);
sv1.smoothScrollTo(0, 20);
return v;
}