ImageView im1_b;
im1_b = (ImageView)findViewById(R.id.b_01_b);
im1_b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
AlertDialog.Builder builder = new AlertDialog.Builder(Next_2Activity.this);
builder.setTitle("Project Gmelon");
builder.setMessage("Are you sure set Wallpaper?");
builder.setNegativeButton("NO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(),
"You Select NO", Toast.LENGTH_LONG) .show();
}
});
builder.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
WallpaperManager myWallpaperManager
= WallpaperManager.getInstance(getApplicationContext());
try {
myWallpaperManager.setResource(R.drawable.b_01_i);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Toast.makeText(getApplicationContext(),
"Setting Complete, Thanks.", Toast.LENGTH_LONG) .show();
}
});
builder.show();
}
});
我写了这样的代码来设置壁纸..但是
我的图片设置如下。 (http://wemakeucc.com/1.jpg)
我想要这样.. (http://wemakeucc.com/2.JPG)
我该怎么办??
EDIT1>
ImageView im1_b;
im1_b = (ImageView)findViewById(R.id.b_01_b);
im1_b.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
im1_b.setOnClickListener(new OnClickListener() {
答案 0 :(得分:0)
如果您想在代码中执行此操作,可以执行以下操作:
YOUR_IMAGE_VIEW.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
如果您愿意,可以选择使用其他比例类型而不是CENTER_INSIDE!
如果要在xml中执行此操作,请使用所需的缩放类型设置scaleType属性:
android:scaleType="centerInside"
点击此链接查看比例类型:Scale Types