hun*_*175 320
你应该在scroll.post中运行代码,如下所示:
scroll.post(new Runnable() {
@Override
public void run() {
scroll.fullScroll(View.FOCUS_DOWN);
}
});
Run Code Online (Sandbox Code Playgroud)
Com*_*are 247
scroll.fullScroll(View.FOCUS_DOWN) 也应该工作.
pea*_*ion 75
scroll.fullScroll(View.FOCUS_DOWN)将导致焦点的变化.当有多个可聚焦视图时,这将带来一些奇怪的行为,例如两个EditText.这个问题有另一种方式.
View lastChild = scrollLayout.getChildAt(scrollLayout.getChildCount() - 1);
int bottom = lastChild.getBottom() + scrollLayout.getPaddingBottom();
int sy = scrollLayout.getScrollY();
int sh = scrollLayout.getHeight();
int delta = bottom - (sy + sh);
scrollLayout.smoothScrollBy(0, delta);
Run Code Online (Sandbox Code Playgroud)
这很好用.
Aja*_*tha 41
有时scrollView.post不起作用
scrollView.post(new Runnable() {
@Override
public void run() {
scrollView.fullScroll(ScrollView.FOCUS_DOWN);
}
});
Run Code Online (Sandbox Code Playgroud)
但是,如果你使用scrollView.postDelayed,它肯定会工作
scrollView.postDelayed(new Runnable() {
@Override
public void run() {
scrollView.fullScroll(ScrollView.FOCUS_DOWN);
}
},1000);
Run Code Online (Sandbox Code Playgroud)
小智 35
对我来说最有效的是
scroll_view.post(new Runnable() {
@Override
public void run() {
// This method works but animates the scrolling
// which looks weird on first load
// scroll_view.fullScroll(View.FOCUS_DOWN);
// This method works even better because there are no animations.
scroll_view.scrollTo(0, scroll_view.getBottom());
}
});
Run Code Online (Sandbox Code Playgroud)
ade*_*190 28
我增加工作完美.
private void sendScroll(){
final Handler handler = new Handler();
new Thread(new Runnable() {
@Override
public void run() {
try {Thread.sleep(100);} catch (InterruptedException e) {}
handler.post(new Runnable() {
@Override
public void run() {
scrollView.fullScroll(View.FOCUS_DOWN);
}
});
}
}).start();
}
Run Code Online (Sandbox Code Playgroud)
注意
这个答案是一个真正旧版本的android的解决方法.今天postDelayed没有更多的bug,你应该使用它.
小智 9
我试过了,成功了。
scrollView.postDelayed(new Runnable() {
@Override
public void run() {
scrollView.smoothScrollTo(0, scrollView.getHeight());
}
}, 1000);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
131536 次 |
| 最近记录: |