I am trying to make the screen which fits great on a vertical orientation scroll for a horizontal as it does not fit and does not scroll. I added a scroll view with the single child of linear layout and the views I want inside that. No errors but it still does not scroll when I turn the phone to a horizontal orientation. What am I doing wrong? below is my XML
Thanks
<TextView
android:text="test App"
android:textSize="20dp"
android:layout_gravity="center_horizontal"
android:textColor="#FCFCFC"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
></TextView>
<TextView
android:text=""
android:textSize="20dp"
android:layout_gravity="center_horizontal"
android:textColor="#FCFCFC"
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
></TextView>
<ScrollView
android:layout_width="match_parent"
android:layout_height="400dp"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="Last Name"
android:textSize="15dp"
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FCFCFC"
android:singleLine="true"
></TextView>
<EditText
android:layout_width="fill_parent"
android:id="@+id/editText1"
android:layout_height="wrap_content"
android:text=""
android:singleLine="true"
></EditText>
<TextView
android:text=""
android:textSize="10dp"
android:layout_gravity="center_horizontal"
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
></TextView>
<TextView
android:text="First Name"
android:textSize="15dp"
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FCFCFC"
android:singleLine="true"
></TextView>
<EditText
android:layout_width="fill_parent"
android:id="@+id/editText2"
android:layout_height="wrap_content"
android:text=""
android:textSize="20dp"
android:singleLine="true"
></EditText>
<TextView
android:layout_gravity="center_horizontal"
android:text=""
android:textSize="15dp"
android:layout_width="wrap_content"
android:id="@+id/TextView01"
android:layout_height="wrap_content"
></TextView>
<TextView
android:text="Description"
android:textSize="15dp"
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FCFCFC"
android:singleLine="true"
></TextView>
<EditText
android:layout_width="fill_parent"
android:id="@+id/editText1"
android:layout_height="wrap_content"
android:text=""
android:textSize="15dp"
android:singleLine="false"
android:lines="10"
></EditText>
</LinearLayout>
</ScrollView>
<TextView
android:layout_gravity="center_horizontal"
android:text=""
android:id="@+id/TextView02"
android:textColor="#FCFCFC"
android:textSize="5dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
></TextView>
<Button
android:text="Next"
android:textSize="20dp"
android:layout_gravity="center_horizontal"
android:id="@+id/nextpage"
android:layout_width="150dp"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
></Button>
Your
ScrollViewand it’s contents are always the same size. The view layout doesn’t pay attention to whether or not it’s visible on screen. Currently, the lastTextViewandButtonin your layout are probably also hidden in lanscape mode (I’m assuming all this is wrapped in a rootLinearLayoutsince the root tag is missing). TheScrollViewsimply says, “if my contents are larger then I am, I will scroll them”.You should consider a layout where your top elements hang to the top, your bottom two elements hang to the bottom, and the scrollview fills the space in between. That way, when it comes to landscape the view will be smaller, and the contents will start scrolling within.
Here’s what I THINK you want 🙂
I don’t believe your 400dp height is necessary in this case, because the bottom elements will hang to the bottom of the screen instead of you needing a fixed height to space them out. However, if it is still relevant put it on the
LinearLayoutinside theScrollView, not theScrollViewitself. This is the whole layout, BTW. Not to be inserted inside anything.If that’s not exactly what you are looking for, hopefully it puts you on the right path 🙂
Hope that Helps!