更改ImageView的高度?

时间:2014-04-02 09:58:08

标签: android android-layout android-imageview android-image

我在第一个textView下面有一个imageView,在该图像下面有一个textView。所以我想重新调整imageView的大小以使其具有更小的高度,这样它就不会占用屏幕的一半以上。但到目前为止,当我尝试将高度更改为wrap_content或match_parent时,它仍然是相同的大小。我也试过设置最大高度,但似乎没有做任何事情。

我的xml文件:

<?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> 

感谢。

2 个答案:

答案 0 :(得分:2)

尝试这样,

<?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>

答案 1 :(得分:1)

试着希望它有效:

<?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> 
相关问题