开发者

standard text and image size in android listview

Hi I am reading XML from web and displaying them in a listview. The xml contain an imag开发者_如何学编程e location so I am displaying the image as well along with text. The image size is 48*48 px as suggested here. But when I see the list view in actual device, the image looks very small. Any idea about how to make that image a little bit big?? is there any standard image and text size?? This is my layout:-

<ImageView
    android:id="@+id/logo"
    android:layout_gravity="left"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    />
<TextView 
  android:id="@+id/name"
  android:textSize="16sp" 
  android:textStyle="bold" 
  android:textColor="#2B2B2B" 
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content"
  android:paddingLeft="5dp"
  android:layout_toRightOf="@id/logo"

/>


use dip instead of px. when you use dip, it appears more adjustable and good on different screens.


Use an ImageView like this:

Modify the width and height values to your liking, but use the dip measurement. With the scaleType property you can tell the framework to stretch your image.


Try adding

android:scaleType="center"

to your ImageView XML. This will not scale your image, but center it in your view.


It's bad practice on Android to declare layout size by pixels. This page is straight from Google on the subject: http://developer.android.com/guide/practices/screens_support.html I would do something like this

android:layout_height="wrap_content"
android:layout_width="fill_parent"

and see how that looks. Don't forget to test on multiple screen sizes before you finish. You can do that by creating different AVDs for the emulator.

You can use pixels if you really want to, but remember that its going to look different on different devices.

android:layout_height="96dip"
android:layout_width="fill_parent"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜