Android ZoomControls的使用

我们通常在手机上特别是在访问浏览器的使用后,经常会看到一些玩野会放大缩小,其实很简单。

------------------------ZoomControls的使用。

public class ZoomControllerActivity extends Activity{
	private TextView myTextView;
	private ZoomControls myZoomController;
	private int size = 25;;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.zooncontroller_layout);
		myTextView = (TextView) findViewById(R.id.myTextView);
		myZoomController = (ZoomControls) findViewById(R.id.myZoomController);;
		myZoomController.setOnZoomInClickListener(new OnZoomInTroller());
		myZoomController.setOnZoomOutClickListener(new OnZoomOutTroller());
	}
	/**
	 * 缩小监听器
	 * @author androidstartjack
	 *
	 */

	private class OnZoomInTroller implements OnClickListener{

		@Override
		public void onClick(View v) {
			Toast.makeText(getApplicationContext(), "aaaaaaa", 0).show();
			size = size +2;
			myTextView.setTextSize(size);
		}

	}
	/**
	 * 放大监听器
	 * @author androidstartjack
	 *
	 */
	private class OnZoomOutTroller implements OnClickListener{
		@Override
		public void onClick(View v) {
			size = size -2;
			Toast.makeText(getApplicationContext(), "bbbbbbbbbbbbbbbb", 0).show();
			myTextView.setTextSize(size);
		}

	}
}

------xml代码:

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

    <TextView
        android:id="@+id/myTextView"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="#fe00fe"
        android:gravity="center"
        android:text="this is the study of zoomTroller" />

    <ZoomControls
        android:id="@+id/myZoomController"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal" />

</LinearLayout>

看是不是很简单。当然可以根据需求做出各种各样的大小。

你可能感兴趣的:(android,android,android,android,it,Zoomcontrols,Zoomcontrols,Zoomcontrols,Zoomcontrols,ZoomContr)