I have this layout, scrollview with relative layout, I added scrollview because on smaller devices RelativeLayout alone will cut off parts of the layout that goes over the screen size, so anything bigger than screen height is not visible.
I tried adding to RelativeLayout wrap_content to height,but that did not fix it, so I added scrollview, now the whole layout is shown, but on devices that have bigger screens like nexus 4, the Relative Layout stretches over the screen height, so the user has to scroll to see the bottom textViews.
Anyway I know the problem is with this ImageView that has drawable:src=@drawable/background
This forces the relative layout to take more than screen height, I use centerCrop for the image, the height of the image is 1200, and the height of the nexus 4 is 1280, so the ImageView is supposed to fit the screen but it stretches the whole Layout. The black line is aproximalty where the screen ends and instead of cutting the imageView at that point the RelativeLayout exapnds after that point...
How can I ensure that my RelativeLayout does not go over the screen height on devices with bigger resolution, but on smaller ones to include scrolling for content that can not fit the screen height? Currently I have to scroll to she the bottom textViews on all devices..
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@android:color/black"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/bg"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingLeft="-20dp"
android:scaleType="centerCrop"
android:src="@drawable/background" />
<ImageView
android:id="@+id/trophystack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:paddingTop="20dp"
android:scaleType="center"
android:src="@drawable/trophystack" />
<LinearLayout
android:id="@+id/llTrophyStackLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical"
android:paddingBottom="20dp"
android:paddingTop="20dp" >
<EditText
android:id="@+id/email_address"
android:layout_width="250dp"
android:layout_height="70dp"
android:layout_marginBottom="2dp"
android:background="@android:color/white"
android:drawableLeft="@drawable/usericon2"
android:fontFamily="sans-serif"
android:gravity="center"
android:hint="[email protected]"
android:inputType="textEmailAddress"
android:minWidth="250dp"
android:tag="login_email" />
<EditText
android:id="@+id/password"
android:layout_width="250dp"
android:layout_height="70dp"
android:background="@android:color/white"
android:drawableLeft="@drawable/lock"
android:gravity="center"
android:hint="********"
android:inputType="textPassword"
android:tag="login_password" />
<Button
android:id="@+id/doLogin"
android:layout_width="250dp"
android:layout_height="70dp"
android:layout_marginTop="20dp"
android:background="@drawable/buttontexture1"
android:minWidth="200dp"
android:onClick="goQueue"
android:text="Sign In"
android:textColor="@android:color/white" />
</LinearLayout>
<TextView
android:id="@+id/forgot_password_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
android:layout_marginLeft="20dp"
android:text="Forgot password?"
android:textColor="#FFFFFF"
android:textSize="16dp"
android:textStyle="bold" />
<TextView
android:id="@+id/sign_up_text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="20dp"
android:layout_marginRight="20dp"
android:clickable="true"
android:text="Sign up"
android:textColor="@android:color/white"
android:textSize="19dp"
android:textStyle="bold" />
<TextView
android:id="@+id/sign_up_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
android:layout_marginRight="2dp"
android:layout_toLeftOf="@id/sign_up_text2"
android:clickable="true"
android:text="New here?"
android:textColor="@android:color/white"
android:textSize="16dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/sign_up_text"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_below="@id/llTrophyStackLogin"
android:background="#0000"
android:minHeight="50dp"
android:onClick="doSwipe"
android:textColor="@android:color/white" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignRight="@id/forgot_password_text"
android:layout_below="@id/llTrophyStackLogin"
android:background="#0000"
android:minHeight="50dp"
android:onClick="doForgotPassword"
android:textColor="@android:color/white" />
</RelativeLayout>
</ScrollView>