android - 改变ImageView的高度?

标签 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> 

谢谢。

最佳答案

试试看,

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

关于android - 改变ImageView的高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22807821/

相关文章:

Android,以抽屉和谷歌地图为 fragment 的主要 Activity

android - 低于 L 的 ImageView 色调无法引用主题属性

Android 支持和额外的 Ivy 设置

java - 如何在java中过滤数组列表

android - 如何自定义选项卡操作栏

android - 布局高度应该是布局宽度的函数

java - 如何为从网络上获取的图像创建图像占位符?

java - Android setImageResource 导致应用程序崩溃

android - 在Android中获取可见 map 的半径

java - 如何获得当前日期之前的最后一个星期日?