ZoomControls控件

如图:


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <!--
        放大/缩小按钮控件
    -->
    <ZoomControls android:id="@+id/zoomControls"
        android:layout_width="wrap_content" android:layout_height="wrap_content"></ZoomControls>

</LinearLayout>


package com.zoomcontrols;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;
import android.widget.ZoomControls;

public class ZoomcontrolsActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.main);

        setTitle("ZoomControls");

        ZoomControls zoomControls = (ZoomControls) this.findViewById(R.id.zoomControls);
        // setOnZoomInClickListener() - 响应单击放大按钮的事件
        zoomControls.setOnZoomInClickListener(new OnClickListener() {
            public void onClick(View v) {
                Toast.makeText(ZoomcontrolsActivity.this, "单击了放大按钮", Toast.LENGTH_SHORT).show();
            }
        });
        
        // setOnZoomOutClickListener() - 响应单击缩小按钮的事件
        zoomControls.setOnZoomOutClickListener(new OnClickListener() {
            public void onClick(View v) {
                Toast.makeText(ZoomcontrolsActivity.this, "单击了缩小按钮", Toast.LENGTH_SHORT).show();    
            }
        });

    }
}


你可能感兴趣的:(Zoomcontrols)