调整Imageview的大小

时间:2011-05-02 20:51:07

标签: android android-layout android-xml

我正在寻找几天,我找不到答案。我正在尝试通过XML调整图像视图的大小。

<TableRow android:layout_height="wrap_content" android:id="@+id/header" android:layout_width="match_parent"> <TableLayout android:layout_height="wrap_content" android:id="@+id/logo" android:layout_width="wrap_content" android:layout_weight="1"> <ImageView android:src="@drawable/iconwide" android:id="@+id/imageView1" android:layout_width="match_parent" android:layout_height="match_parent"></ImageView> </TableLayout> <TableLayout android:layout_height="wrap_content" android:id="@+id/user" android:layout_width="wrap_content" android:layout_weight="1"> <TextView android:layout_width="wrap_content" android:text="@string/user" android:layout_height="wrap_content" android:id="@+id/suser" android:layout_weight="1"></TextView> </TableLayout> </TableRow>

知道如何调整大小吗?它看起来像这样:http://i55.tinypic.com/2h3u4hh.png

1 个答案:

答案 0 :(得分:3)

如果您想要特定尺寸,可以使用density independent pixels通过XML指定该尺寸。在mdpi屏幕上,1 dp = 1像素,在所有屏幕上100dp大致等于1英寸。

<ImageView
    android:src="@drawable/iconwide"
    android:id="@+id/imageView1"
    android:layout_width="200dp"
    android:layout_height="50dp"/>
相关问题