2014-04-02 71 views
1

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

我的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> 

感谢。

+0

有编辑我现在答检查 –

回答

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> 
+0

这似乎并没有为我工作已经显示的影像屏幕上的大小仍然相同。 – user1832478

+0

我已经编辑我的答案,现在请检查。 –

+0

感谢它似乎正在为高度工作,但图像的宽度不再延伸。现在图像看起来像是屏幕中央的一个小小盒子。 – user1832478

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>