Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Imageview gets blurry

This app is supposed to display images in which the students can count up what the money is worth in total, and then input the value in a editText text box, which is then compared against a stored value. Unfortunately, when I try to switch activities past a certain point (there are 11 active activities, with three of them displaying images fine), the images start blurring and the coins are hard to distinguish from each other. I do not know whether this is a Java or XML error, however I have pasted the code below. The following is XML code.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".Ldsm" >

<LinearLayout
    android:id="@+id/linearLayout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:orientation="vertical" >

    <Button
        android:id="@+id/submitButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/submit" />
</LinearLayout>

<TextView
    android:id="@+id/userQuestion"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/linearLayout"
    android:layout_alignLeft="@+id/userAnswer"
    android:layout_marginBottom="30dp"
    android:text="@string/how_many_coins_total"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<EditText
    android:id="@+id/userAnswer"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/linearLayout"
    android:layout_alignParentLeft="true"
    android:layout_marginLeft="16dp"
    android:ems="10"
    android:inputType="number" >

    <requestFocus />
</EditText>

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/userQuestion"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="50dp"
    android:layout_marginTop="118dp" >

</LinearLayout>

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/userQuestion"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_alignRight="@+id/linearLayout"
    android:src="@drawable/ic_coin4" />

That's just one of the 7 screens that look blurry when they display the images. The following is the Java code for the same activity.

package com.example.ldsm3;

import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText; 
import com.example.ldsm3.Problem5;

public class Problem4 extends Activity 
{
 private final int COIN3_SCREEN_ANSWER = 95;

public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_problem4);

    Button submitButton =  (Button)findViewById(R.id.submitButton);
    submitButton.setOnClickListener(submitButtonListener);
}

public boolean onCreateOptionsMenu(Menu menu) 
{
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

private OnClickListener submitButtonListener = new OnClickListener()
{
    public void onClick(View arg0)
    {
        EditText editText =  (EditText)findViewById(R.id.userAnswer);
        int userAnswerValue = Integer.parseInt(editText.getText().toString());

        // Build the Alert Dialog
        android.app.AlertDialog.Builder alert = new AlertDialog.Builder(Problem4.this);
        alert.setTitle("Answer");
        alert.setCancelable(false);
        if(userAnswerValue == COIN3_SCREEN_ANSWER)
        {
            alert.setMessage("Congratulations!!!");
        }
        else
        {
            alert.setMessage("Sorry, that's not right.");
        }
        alert.setPositiveButton("OK",new DialogInterface.OnClickListener() 
        {
            public void onClick(DialogInterface dialog,int id) 
            {
                Intent nextCoinScreenIntent = new Intent(Problem4.this, Problem5.class);
                startActivity(nextCoinScreenIntent);
            }
        });
        alert.show(); 

    }


};

    }

And this a screenshot when it is running on a Nexus 10:

enter image description here

Please let me know if any more information is needed.

like image 534
javathunderman Avatar asked Feb 09 '14 23:02

javathunderman


2 Answers

It seems like it was fetching the icons that were not designed for the particular screen size. You can fix this by going to the workspace and deleting every icon that is any other folder besides the "drawable" one. (With the exception of the ic_launcher icon, as that is the one that allows you to display your app in the Android app menu and will not get blurry.)

like image 68
javathunderman Avatar answered Sep 30 '22 02:09

javathunderman


Better than your solution would be to make sure the proper resolution file is in every folder. The proper resolution is your desired resolution with the following multipliers, as shown on the Android Design documents:

enter image description here

like image 34
PearsonArtPhoto Avatar answered Sep 30 '22 02:09

PearsonArtPhoto