如何调整图片的大小?

问题描述:

Hy!如何调整图片的大小?

我在视图上有两张图片,在按钮上有一个按钮。

Screenshot

XML:

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_height="wrap_content" android:layout_width="fill_parent" android:orientation="vertical"> 
    <TextView android:layout_height="wrap_content" android:id="@+id/mainscreen" android:layout_width="fill_parent" android:text="Selected Channel" android:gravity="center" android:layout_alignParentTop="true"></TextView> 
    <ImageView android:id="@+id/ImageView01" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView> 
    <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/mainscreen_state" android:layout_above="@+id/mainscreen_btchange"></TextView> 
    <ImageView android:layout_width="wrap_content" android:layout_centerHorizontal="true" android:layout_height="wrap_content" android:id="@+id/ImageAd" android:layout_gravity="center" android:layout_below="@+id/mainscreen"></ImageView> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent"> 


    <Button android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:id="@+id/mainscreen_btchange" 
     android:text="Change State"></Button> 


    </RelativeLayout> 
    </LinearLayout> 

我的问题:如何收缩,布局的所有元素都显示的图片?

对于更复杂的布局,我需要确保一堆物品都可以显示,我通常以RelativeLayout作为最外层的容器。我使用layout_alignParentTop和layout_alignParentBottom(在垂直布局的情况下,你似乎是这样)停靠任何需要在肢体上的需求,然后我努力使下一组元素与它们相关。基本上,从边缘开始,工作你的方式。

所以,在你的情况下,按钮应该有属性android:layout_alignParentBottom="true",和电视应该有android:layout_above="@+id/mainscreen_btchange"。顶部的TextView的应有android:layout_alignParentTop="true"和其下方的Im​​ageView应该有android:layout_below="@+id/mainscreen"

+0

错误:未发现在包“机器人”属性“layout_alignBelow”资源标识符 – user547995 2011-02-15 16:33:47