I tried all the answers that i found in the Android section with out any success before i post this question...
for some reason the image quality in the device is poor and in Eclipse and in the virtual device is very good
look on the screenshot example:
example http://img714.imageshack.us/img714/1358/84044294.jpg
what should i do?
i try to make the image with 72dpi and 300 dpi, the PNG/JPG resolution is 1280x800
but nothing works...
Please help!!
This is my LiveNewsActivity.java maybe i'm doing something wrong?
package com.prog.livenews;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.PixelFormat;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
public class LiveNewsActivity extends Activity {
/** Called when the activity is first created. */
//############################
//######### VARS #############
Button login;
Button register;
//############################
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.test);
getWindow().setFormat(PixelFormat.RGBA_8888);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap gradient = BitmapFactory.decodeResource(getResources(), R.drawable.bg, options);
findViewById(R.id.frameLayout1).setBackgroundDrawable(new BitmapDrawable(gradient));
login = (Button) findViewById(R.id.main_login_button);
register = (Button) findViewById(R.id.main_register_button);
login.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.prog.livenews.LOGIN"));
}
});
register.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.prog.livenews.REGISTER"));
}
});
}
}
try it:
put it before setContentView(layoutId) on your first activity
getWindow().setFormat(PixelFormat.RGBA_8888);
and after call setContentView(layoutId) in your first activity you put the bellow code:
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
options.inDither = true;
options.inScaled = false;
options.inDither = false;
options.inPurgeable = true;
Bitmap preparedBitmap = BitmapFactory.decodeResource(yourAppName.getSharedApplication().getResources(),
R.drawable.bg, options);
Drawable background = new BitmapDrawable(preparedBitmap);
((LinearLayout) findViewById(R.id.yourLayoutId))
.setBackgroundDrawable(background);
and finnaly you put your xml images in res/drawable "if you have xml images" folder and the png, jpeg and others normals images you put in res/drawable-hdpi folder.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With