I am doing:
android:background="@drawable/mobile_vforum_bg"
in the main.xml file to just set the BG.
It works, just the quality of the image is very poor when viewed on the emulator. Its a PNG at 320x480 (96dpi and the same in the low, med and high folder). When I was using Titanium to build my android app, it looked fine. I am now using eclipse and java and it looks bad.
Select File > Export as > PNG from the menu. Change the Zoom to a higher percentage, 200% or 300%, for example. Set the other options as you need, then click Export. When you use the PNG image in a document or on the web, restrict its dimensions to effectively display the image at a higher resolution (DPI).
Your image may appear blurry due to a compression issue. Whenever you resize an image, text or graphic, you are also shrinking and enlarging the pixels of that image/text. While you shouldn't expect a loss in quality with minor resizing, any substantial resizing of JPG images will result in a visibly poorer image.
In contrast, PNG files benefit from lossless compression. This means no data is lost when the image is compressed — the quality stays the same no matter how many times you edit and save the file. The image won't become blurry or distorted, making PNGs ideal for sharp logos and graphs containing lots of figures.
I had this issue while setting a high resolution image as an activity's background and I was able to solve it by using the following java code from the Activity's onCreate()
method.
BitmapFactory.Options myOptions = new BitmapFactory.Options();
myOptions.inDither = true;
myOptions.inScaled = false;
myOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
myOptions.inDither = false;
myOptions.inPurgeable = true;
Bitmap preparedBitmap = BitmapFactory.decodeResource(yourAppName.getSharedApplication().getResources(),
R.drawable.yourImage, myOptions);
Drawable background = new BitmapDrawable(preparedBitmap);
((LinearLayout) findViewById(R.id.yourLayoutId))
.setBackgroundDrawable(background);
Also don't set the background from the layout xml if you are using this code. In case this doesn't work try setting the following lines outside the application tag in AndroidManifest.xml
<supports-screens android:largeScreens="true"
android:normalScreens="true" android:smallScreens="true"
android:anyDensity="true" />
Hope this Helps!!!
Try to move it to the "res/drawable_hdpi" folder, that worked for me.
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