开发者

android grid view with images (images shrinking and looking blur)

android grid view with images (images shrinking and looking blur)

I have to show 7 icons on the home screen of my application .To do this i have arranged the icons on the grid view using image view to show images .On emulator it looks absolutely fine but images shrink and look blur ,when i deploy the application on LG Optimus p350 please help me how to show the images clearly of actual size :

The code i tried are :

<GridView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/gridview" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:columnWidth="61dp"
    android:numColumns="3" android:verticalSpacing="10dp"
    android:horizontalSpacing="10dp" android:stretchMode="spacingWidthUniform"
    android:gravity="center" android:layout_gravity="center" />

icon size is 61*80

EDIT :

<supports-screens android:smallScreens="true"
        android:normalScreens="true" android:largeScreens="true"
         android:anyDensity="true"/>

Please see the image and the code On emulator the output is shown like this.I want to show output on de开发者_开发知识库vice also with this clarity.Please guide

see second screen shot (blur on qvga emulator) and please guide me how to correct it ..

android grid view with images (images shrinking and looking blur)


The images don't appear blurred to me. They are just smaller due to higher screen resolution. But the text does look blurred.

So I would suggest to use a combination of ImageView and TextView. To separate the text and image. The text will be scaled appropriately. You can also provide multiple image sets for different resolutions.

EDIT: You can create a grid item layout similar to this:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" 
android:gravity="bottom"
android:layout_width="wrap_content" 
android:layout_gravity="bottom">

<ImageView android:id="@+id/thumbnailImage"
    android:layout_height="70dp" 
    android:layout_width="fill_parent"      
    android:gravity="center_horizontal" />

<TextView android:id="@+id/thumnailTitle" android:text="TextView"
    android:layout_height="wrap_content" 
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:layout_width="fill_parent"
    android:gravity="center_horizontal|bottom" />
</LinearLayout>

Create a custom grid adapter extending BaseAdapter class:

public class MyGridAdapter extends BaseAdapter
{...}

associate the adapter with your grid:

adapter = new MyGridAdapter();

GridView gridView = (GridView) findViewById(R.id.gridView);
gridView.setAdapter(adapter);

Then it is just a matter of filling the items to the grid with the getView adapter method:

public View getView(int position, View convertView, ViewGroup parent)
{
   // assuming the grid item layout is named "grid_item"
   View view = inflater.inflate(R.layout.grid_item, null);

   TextView text = (TextView) view.findViewById(R.id.thumnailTitle);
   text.setText("Test");

   ImageView thumbnail = (ImageView) view.findViewById(R.id.thumbnailImage);
...


Are you providing multiple resolution resources? Read carefully this article about Supporting Multiple Screens.

I don't think the images shrink, they only look smaller because your phone has a higher density or resolution than the emulator you were testing on.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜