| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx

Android开发教程ZoomControls控件详解

0
Java XML C/C++ Go Android开发 17255 次浏览
Android开发中,ZoomControls是一组可缩放的控件。它包含俩个按钮(放大按钮、缩小按钮),下面是效果图:

正常
 

放大

 

缩小

 

我们可以通过以下代码来查看具体实现方式:

XML代码(main.xml):
<?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" 
android:background="#ffffff"> 
<!-- 放大/缩小按钮控件——> 
<ZoomControls 
android:id="@+id/zoomControls" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content"/>
</LinearLayout>

java代码:麦子学院(http://www.maiziedu.com/)

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 HelloZoomControls extends Activity{ 
@Override 
public void onCreate(Bundle savedInstanceState){ 
super.onCreate(savedInstanceState); 
setContentView(R.layout.main); 
ZoomControls zoomControls = (ZoomControls) this.findViewById(R.id.zoomControls); 
// setOnZoomInClickListener() - 响应单击放大按钮的事件 zoomControls.setOnZoomInClickListener(new OnClickListener(){ 
@Override 
public void onClick(View v){ 
Toast.makeText(getBaseContext(),"单击了放大按钮",Toast.LENGTH_SHORT).show(); 
} 
}); 
// setOnZoomOutClickListener() - 响应单击缩小按钮的事件 zoomControls.setOnZoomOutClickListener(new OnClickListener(){ 
@Override 
public void onClick(View v){ 
Toast.makeText(getBaseContext(),"单击了缩小按钮",Toast.LENGTH_SHORT).show(); 
} 
}); 
}
}

文章转自麦子学院(http://www.maiziedu.com/)-国内最专业的IT职业在线学习平台。

3个答案

0
0

Is there a copy of Android international agency and digital distribution handbook - need it to make a proper citation and do my homework online for sale. I study Android design and technologies at Jiangsu University. I thought about this research topic on ZoomControls, but it seemed too complicated.

0
不是俺想要的。。。