I have a LinearLayout that is works great on orienation change. I then wrapped the LinearLayout in a ScrollView and now I have a problem. The vertical scrolling works fine but when there is an orientation change to landscape mode the View scrolls down a bit so now the top of the layout is cut off. The ScrollView appears to be responding to requestFocus() code on an EditText line that is just below the top of the View. But the View is plenty big enought to show the top of the View and the EditText line. How do I force the View after an orientation change to not scroll down so that it can show the top of the layout and the EditText line?
partial layout file:
?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:focusableInTouchMode="true"
tools:context=".CardViewActivity">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" >
</include>
<ScrollView
android:id="@+id/ScrollView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<LinearLayout
android:id="@+id/LinearLayout1"
style="@style/scrollbar_shape_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/rounded_corner"
android:layout_marginLeft="6dp"
android:layout_marginStart="6dp"
android:layout_marginRight="6dp"
android:layout_marginEnd="6dp"
android:layout_marginTop="6dp"
android:layout_marginBottom="6dp"
android:useDefaultMargins="false"
android:orientation="vertical" >
...
partial Activity file:
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cardviewinput);
cListenerEditText = (ListenerEditText) findViewById(R.id.CEditText);
cListenerEditText.requestFocus();