缩放控件ZoomControls使用

ZoomControls组件介绍:

通过使用缩放控制zooncontrols,可以实现组件的放大和缩小的功能。实现对控件的控制。主要使用andorid.widget.ZoomControls组件完成.该组件继承android.widget.LinearLayout.

常用操作方法:

 

step1.在main.xml中添加如下代码

<?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" >

    <TextView
        android:id="@+id/text"
       
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="QQ的末日到了 " />
    <ZoomControls
        android:id="@+id/zoomControls"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="bottom"
        />

</LinearLayout>

 

step2.在activity中编写如下代码

package com.activty;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.ZoomControls;
/**
 * 缩放 控制zooncontrols 控制显示文字的大小
 * @author Administrator
 *
 */
public class ZoomControlsProjectActivity extends Activity {
    /** Called when the activity is first created. */
 private ZoomControls zoomControls=null;
 private TextView textView=null;
 private int size=0;//保存字体大小
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         setContentView(R.layout.main);
         this.zoomControls=(ZoomControls) findViewById(R.id.zoomControls);
         this.textView=(TextView) findViewById(R.id.text);
         this.zoomControls.setOnZoomInClickListener(new OnZoomInClickListenerImpl());
         this.zoomControls.setOnZoomOutClickListener(new OnZoomOutClickListenerImpl());
    }
    private class OnZoomInClickListenerImpl implements OnClickListener{

  @Override
  public void onClick(View v) {
   // TODO Auto-generated method stub
   ZoomControlsProjectActivity.this.size=size+2;
   ZoomControlsProjectActivity.this.textView.setTextSize(size);
   
  }
     
    }
    private class OnZoomOutClickListenerImpl implements OnClickListener{

  @Override
  public void onClick(View v) {
   // TODO Auto-generated method stub
   ZoomControlsProjectActivity.this.size=size-2;
   ZoomControlsProjectActivity.this.textView.setTextSize(size);
  }
     
    }
   
}

 

 

 

你可能感兴趣的:(android,qq,layout,Class,encoding)