Android - 如何确保 ScrollView 中选中的单选按钮将在屏幕上可见?

Mir*_*lec 1 android radio-button android-layout

我在 DialogPreference 的 ScrollView 中有带有 19 个 RadioButtons 的 RadioGroup。对话框中只有前 7 个 RadioButtons 附近可见。一切正常,只有一个问题。绑定对话框后,如何确保选中的 RadioButton 在屏幕上始终可见?如何以编程方式在 ScrollView 中滚动以显示隐藏的选中 RadioButton ?

感谢您的帮助或建议。

ble*_*enm 5

你应该能够做这样的事情

int top = checkedRadioButton.getTop();
scrollView.scrollTo(0,top);
Run Code Online (Sandbox Code Playgroud)