-1
我使用this image slider,我真的很喜欢它。但我需要缩放选项也可以添加缩放选项吗?Android图像滑块变焦
我使用this image slider,我真的很喜欢它。但我需要缩放选项也可以添加缩放选项吗?Android图像滑块变焦
没有它不支持,但您可以添加此功能是,图像显示在imageview的并且可以添加此功能,例如这下面的代码是你想拥有,并加入到支持
public class Zoom extends View {
private Drawable image;
ImageButton img,img1;
private int zoomControler=20;
public Zoom(Context context){
super(context);
image=context.getResources().getDrawable(R.drawable.j);
//image=context.getResources().getDrawable(R.drawable.icon);
setFocusable(true);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//here u can control the width and height of the images........ this line is very important
image.setBounds((getWidth()/2)-zoomControler, (getHeight()/2)-zoomControler, (getWidth()/2)+zoomControler, (getHeight()/2)+zoomControler);
image.draw(canvas);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode==KeyEvent.KEYCODE_DPAD_UP){
// zoom in
zoomControler+=10;
}
if(keyCode==KeyEvent.KEYCODE_DPAD_DOWN){
// zoom out
zoomControler-=10;
}
if(zoomControler<10){
zoomControler=10;
}
invalidate();
return true;
}
}
马赫迪你好,我不明白如何使用这个可以帮我吗? – Murat