سؤال

I'm searching for few days and I can't find the answer. I'm trying to resize an Image View through 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>

Any idea how to resize it ? It looks like this: http://i55.tinypic.com/2h3u4hh.png

هل كانت مفيدة؟

المحلول

If you would like a specific size, you can specify that size via XML by using density independent pixels. On a mdpi screen, 1 dp = 1 pixel, on all screens 100dp is roughly equal to 1 inch.

<ImageView
    android:src="@drawable/iconwide"
    android:id="@+id/imageView1"
    android:layout_width="200dp"
    android:layout_height="50dp"/>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top