I have one main Activity with layout wrapped into ScrollView like this:
<ScrollView android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="1">
User can scroll up and down and there is some buttons when user scrolls down.
When user presses a button – I run code like this:
public void onClick(View view)
{
Log.d(LOG_TAG, "onClick");
TireView tiat = (TireView)view;
Intent i = new Intent(TrailerInspectionActivity.this, TireInspectionActivity.class);
i.putExtra(TireInspectionActivity.INTENT_TIRE_NUMBER, tiat.getNumber());
if (tiat.getDepth() != -1)
{
i.putExtra(TireInspectionActivity.INTENT_DEPTH, tiat.getDepth());
i.putExtra(TireInspectionActivity.INTENT_PRESSURE, tiat.getPressure());
}
TrailerInspectionActivity.this.startActivityForResult(i, REQUEST_CODE_TIRE_INSPECTION_ACTIVITY);
}
TireInspectinActivity starts and shows like popup – I use theme.Dialog for that.
As soon as user clicks and popups show up – main activity ScrollView scrolls all way up.
Is there any way to prevent this from happening?
You should record the current position of your ScrollView (getScrollY) and restore that in onResume for your activity.