[英]How to add TextView's programatically to a ScrollView with a LinearLayout and existing TextViews
[英]Is it possible to scroll the ScrollView that has vertical LinearLayout that has several TextViews (variable number) to the beginning of some TextView?
我不知道是否有可能。 我有一個ScrollView,垂直LinearLayout子項,我在這個垂直LinearLayout上以編程方式擴展TextViews數組。
現在,讓我們說,我想用ScrollView打開這個Activity滾動到textView[4]
這有可能實現嗎?
是的,您可以使用以下方法:
scrollView.post(
new Runnable() {
@Override
public void run() {
new CountDownTimer(1500, 20) {
@Override
public void onTick(long millisUntilFinished) {
scrollView.scrollTo(0, (int) (textViewAbove.getBottom()-millisUntilFinished));
}
@Override
public void onFinish() {
}
}.start();
}
}
);
其中textViewAbove
是textView[4]
上方的TextView
,在這種情況下是textView[3]
。
希望能幫助到你!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.