本文整理匯總了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;
}