Android 更改ImageView的高度?

Android 更改ImageView的高度?,android,android-layout,android-imageview,android-image,Android,Android Layout,Android Imageview,Android Image,我在第一个文本视图下面有一个图像视图,在该图像下面有一个文本视图。因此,我想重新调整imageView的大小,使其具有更小的高度,这样它就不会占用超过一半的屏幕。但到目前为止,当我尝试将高度更改为wrap_content或match_parent时,它仍然是相同的大小。我也试着设定一个最大高度,但似乎什么也没做 我的xml文件: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http:

我在第一个文本视图下面有一个图像视图,在该图像下面有一个文本视图。因此,我想重新调整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> 

"
谢谢。

像这样试试

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

试试这个,希望它能奏效:

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

"

have edit my ans now check edit似乎对我不起作用屏幕上显示的图像大小仍然相同。感谢它似乎对高度起作用,但图像的宽度不再延伸。图像现在显示为屏幕中央的一个小方框。是的,但您可以根据需要设置图像高度,如果这对您有效,则标记为正确,其他人将很容易找到解决方案。