SW scroll to the top on activity create

This commit is contained in:
Milos Kozak 2018-05-24 00:13:59 +02:00
parent d642418e02
commit 35c07d1e60
2 changed files with 7 additions and 0 deletions

View file

@ -8,6 +8,7 @@ import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import com.squareup.otto.Subscribe;
@ -36,6 +37,8 @@ public class SetupWizardActivity extends AppCompatActivity {
//logging
private static Logger log = LoggerFactory.getLogger(SetupWizardActivity.class);
ScrollView scrollView;
private SWDefinition swDefinition = new SWDefinition();
private List<SWScreen> screens = swDefinition.getScreens();
private int currentWizardPage = 0;
@ -47,6 +50,8 @@ public class SetupWizardActivity extends AppCompatActivity {
LocaleHelper.onCreate(this, "en");
setContentView(R.layout.activity_setupwizard);
scrollView = (ScrollView) findViewById(R.id.sw_scrollview);
Intent intent = getIntent();
currentWizardPage = intent.getIntExtra(SetupWizardActivity.INTENT_MESSAGE, 0);
if (screens.size() > 0 && currentWizardPage < screens.size()) {
@ -126,6 +131,7 @@ public class SetupWizardActivity extends AppCompatActivity {
SWItem currentItem = currentScreen.items.get(i);
currentItem.generateDialog(this.findViewById(R.id.sw_content_fields), layout);
}
scrollView.smoothScrollTo(0,0);
}
private void updateButtons() {

View file

@ -27,6 +27,7 @@
tools:text="Title" />
<ScrollView
android:id="@+id/sw_scrollview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">