Friday, 25 March 2016

XML : LinearLayout pushing TextView out of the screen

I'm fairly new to Android app development and I have run into a bit of a problem.

I have a LinearLayout with 2 ImageButtons in it and another LinearLayout with a TextView on the top as you can see here -

Looks pretty-ish

However, I have tried to add another LinearLayout to add more things into, but it starts to push my Welcome message out of the screen

I add another LinearLayout and this happens

Here's the XML for the screen

  <?xml version="1.0" encoding="utf-8"?>    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"            android:layout_width="fill_parent"            android:layout_height="fill_parent"            android:orientation="vertical"            android:layout_weight="0.6"            android:id="@+id/layout_home">    <ScrollView      android:layout_width="fill_parent"      android:layout_height="wrap_content"      android:id="@+id/scrollView"      >        <LinearLayout          android:layout_width="match_parent"          android:layout_height="wrap_content"          android:layout_gravity="center"          android:orientation="vertical"          android:paddingLeft="0dp"          android:paddingRight="0dp"          >            <LinearLayout              android:layout_width="match_parent"              android:layout_height="wrap_content"              android:measureWithLargestChild="false"              android:longClickable="false">                <TextView                  android:layout_width="wrap_content"                  android:layout_height="fill_parent"                  android:textAppearance="?android:attr/textAppearanceLarge"                  android:text="Welcome"                  android:id="@+id/textView4"                  android:textSize="60dp"                  android:layout_weight="1"                  android:layout_gravity="top"/>          </LinearLayout>            <LinearLayout              android:orientation="horizontal"              android:layout_width="match_parent"              android:layout_height="56dp"              android:paddingLeft="5dp"              android:paddingRight="5dp"              android:background="#5cfca1">            </LinearLayout>            <LinearLayout              android:orientation="horizontal"              android:layout_width="match_parent"              android:layout_height="wrap_content"              android:paddingLeft="5dp"              android:paddingRight="5dp">                <ImageButton                  android:id="@+id/whatisit"                  android:layout_width="fill_parent"                  android:layout_height="100dp"                  android:layout_weight="0.5"/>                <ImageButton                  android:id="@+id/contact"                  android:layout_width="fill_parent"                  android:layout_height="100dp"                  android:layout_weight="0.5"/>          </LinearLayout>            <LinearLayout              android:orientation="horizontal"              android:layout_width="match_parent"              android:layout_height="wrap_content"              android:paddingRight="5dp"              android:paddingLeft="5dp"              android:paddingBottom="300dp">                <ImageButton                  android:id="@+id/howcanitreatit"                  android:layout_width="fill_parent"                  android:layout_height="100dp"                  android:layout_weight="0.5"/>                <ImageButton                  android:id="@+id/disclaimer"                  android:layout_width="fill_parent"                  android:layout_height="100dp"                  android:layout_weight="0.5"                  android:adjustViewBounds="false"/>          </LinearLayout>        </LinearLayout>  </ScrollView>    

I've looked at other questions but they've seemed to do a lot different in terms of setting out their layout and have a lot more elements and such.

Why is it pushing the welcome message out? What am I doing wrong here?

Also feel free to scrutinise anything. The more mistakes I've done, the better

No comments:

Post a Comment