Android - how to ensure that checked radiobutton in ScrollView will be visible on screen?

2011-11-02 android android-layout radio-button

I have RadioGroup with 19 RadioButtons in a ScrollView in DialogPreference. There are visible only around first 7 of RadioButtons in dialog. All is working fine, only one question. How to ensure that checked RadioButton will be always visible on screen after bind the dialog? How to scroll in ScrollView programmatically to show hidden checked RadioButton ?

Thank you for your help or suggestions.


You should be able to do something like this

int top = checkedRadioButton.getTop();

This is what worked for me.

final Scrollview scrollview = findViewById(;
final RadioGroup rg = findViewById(;
int position = //checked position Runnable() {
        public void run() {
            scrollView.scrollTo(0, rg.getChildAt(position).getTop());