Reputation: 2053
I am having an issue with an ImageView and a TextView. I am having a problem where when I set the layout width and height of the ImageView to "fill_parent", my TextView I would like to have showing under it gets pushed off the screen.
I must have the ImageView to fill the rest of the screen that's why I am using "fill_parent" for the height and width. I've tried using "fill_parent" just for the width and "wrap_content" for the height but then the whole image gets resized(smaller) as if I were using "wrap_content" for both.
Here's my XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background_x_high"
android:orientation="vertical" >
<Gallery
android:id="@+id/Gallery01"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</Gallery>
<ImageView
android:id="@+id/ImageView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:paddingBottom="8dp"
android:paddingTop="20dp"
android:layout_below="@+id/Gallery01" >
</ImageView>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/Textgoeshere"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="15sp"
android:textColor="#CCCCCC"
android:typeface="serif"
android:textAlignment="gravity"
android:layout_below="@+id/ImageView01" />
</RelativeLayout>
Upvotes: 1
Views: 890
Reputation: 5574
Try this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ActivityHome"
android:orientation="vertical"
android:weightSum="1"
>
<Gallery
android:id="@+id/Gallery01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
</Gallery>
<ImageView
android:id="@+id/ImageView01"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:paddingBottom="8dp"
android:background="@drawable/ic_launcher"
android:layout_weight="1"
android:paddingTop="20dp"
>
</ImageView>
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Textgoeshere"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="15sp"
android:textColor="#CCCCCC"
android:typeface="serif"
android:textAlignment="gravity"
android:layout_gravity="bottom"
/>
</LinearLayout>
Upvotes: 1
Reputation: 24181
You can align your TextView
at the bottom of the parent layout , and then put your ImageView
below the Gallery
, and above the TextView
. this way it will fill the rest of space in your layout :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background_x_high"
android:orientation="vertical" >
<Gallery
android:id="@+id/Gallery01"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</Gallery>
<TextView
android:id="@+id/textView1"
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="goes here"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="15sp"
android:textColor="#CCCCCC"
android:typeface="serif"
android:textAlignment="gravity" />
<ImageView
android:id="@+id/ImageView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:paddingBottom="8dp"
android:paddingTop="20dp"
android:layout_below="@+id/Gallery01"
android:layout_above="@+id/textView1" >
</ImageView>
</RelativeLayout>
Upvotes: 1