Android:ZoomControls控件

时间:2021-11-14 19:35:14

ZoomControls控件

//_ZoomControls.java
public class _ZoomControls extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
this.setContentView(R.layout.zoomcontrols);
setTitle("ZoomControls");
ZoomControls zoomControls=(ZoomControls)findViewById(R.id.zoomControls);
//响应单击放大按钮的事件
zoomControls.setOnZoomInClickListener(new OnClickListener(){
public void onClick(View v){
Toast.makeText(_ZoomControls.this, "单击了放大按钮", Toast.LENGTH_SHORT).show();
}
});
//响应单击缩小按钮的事件
zoomControls.setOnZoomOutClickListener(new OnClickListener() {
public void onClick(View v) {
Toast.makeText(_ZoomControls.this, "单击了缩小按钮", Toast.LENGTH_SHORT).show();
}
});
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" >
<!-- 放大/缩小按钮控件-->
<ZoomControls
android:id="@+id/zoomControls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"> </ZoomControls>
</LinearLayout>

参考链接:

代码下载链接: