Ofe*_*ear 4 layout android image
在我发布这个问题之前,我尝试了在Android部分找到的所有答案,但没有任何成功......
出于某种原因,设备中的图像质量很差,在Eclipse和虚拟设备中
看起来非常好看截图示例:
示例http://img714.imageshack.us/img714/1358/84044294.jpg
我该怎么办?我尝试用72dpi和300 dpi制作图像,PNG/JPG分辨率为1280x800,
但没有任何作用......
请帮忙!!
这是我的LiveNewsActivity.java也许我做错了什么?
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"));
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
试试吧:
将它放在第一个活动的setContentView(layoutId)之前
getWindow().setFormat(PixelFormat.RGBA_8888);
Run Code Online (Sandbox Code Playgroud)
在你的第一个活动中调用setContentView(layoutId)后,你把下面的代码:
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);
Run Code Online (Sandbox Code Playgroud)
并且你把你的xml图像放在res/drawable"如果你有xml图像"文件夹和png,jpeg和其他普通图像放在res/drawable-hdpi文件夹中.
希望这可以帮助.
| 归档时间: |
|
| 查看次数: |
4592 次 |
| 最近记录: |