user1832478
user1832478

Reputation: 559

Changing the height of ImageView?

I have an imageView below my first textView and a textView below that image. So I want to re-size the imageView to have a smaller height so that it would not take up more than half the screen. But so far when I try to change the height to either wrap_content or match_parent however it is just still the same size. I also tried setting a max height but does not seem to be doing anything.

My xml file:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg_gblue" >

    <TextView
        android:id="@+id/faq_story1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/faqpt1"
        android:textSize="15sp" />

    <ImageView
        android:id="@+id/faq_pic1"
        android:src="@drawable/skull"
        android:layout_width="wrap_content"
        android:layout_height="5dp"
        android:maxHeight="10dp"
        android:layout_above="@+id/faq_story2"
        android:layout_below="@+id/faq_story1"
        />

    <TextView
        android:id="@+id/faq_story2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:text="@string/faqpt2"/>"

</RelativeLayout> 

Thanks.

Upvotes: 1

Views: 101

Answers (2)

InnocentKiller
InnocentKiller

Reputation: 5234

Try it like this,

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <TextView
        android:id="@+id/faq_story1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/faqpt1"
        android:textSize="15sp" />

    <TextView
        android:id="@+id/faq_story2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:text="@string/faqpt2" />

    <ImageView
        android:id="@+id/faq_pic1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/faq_story2"
        android:layout_alignParentLeft="true"
        android:src="@drawable/skull"
        android:layout_below="@+id/faq_story1" />

</RelativeLayout>

Upvotes: 2

Farhan Shah
Farhan Shah

Reputation: 2342

try this hope it is worked:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_gblue" >

<TextView
    android:id="@+id/faq_story1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/faqpt1"
    android:textSize="15sp" />

<ImageView
    android:id="@+id/faq_pic1"
    android:src="@drawable/skull"
    android:layout_width="match_parent"
    android:layout_height="25dp"
    android:maxHeight="10dp"

    android:layout_below="@+id/faq_story1"
    />

<TextView
    android:id="@+id/faq_story2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/faq_pic1"

    android:text="@string/faqpt2"/>"

</RelativeLayout> 

Upvotes: 1

Related Questions