• 控件:ZoomControls 缩放控制


    main.xml

    View Code
    <?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">
    <TextView
    android:id="@+id/text"
    android:layout_width
    ="wrap_content"
    android:layout_height
    ="wrap_content"
    android:text
    ="Android控件---ZoomControls"
    android:textSize
    ="10px" />
    <ZoomControls
    android:id="@+id/zoomcontrols"
    android:layout_gravity
    ="bottom"
    android:layout_width
    ="wrap_content"
    android:layout_height
    ="wrap_content" />
    </LinearLayout>

    MyZoomControlsDemo.java

    View Code
    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;

    public class MyZoomControlsDemo extends Activity {
    // 缩放组件
    private ZoomControls zoomControls;
    private int size = 10; // 默认文字大小
    private TextView text; // 文本显示组件

    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // 调用默认布局
    super.setContentView(R.layout.main);
    this.zoomControls = (ZoomControls) findViewById(R.id.zoomcontrols);
    // 取得组件
    this.text = (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 view) {
    // 更改文字大小
    MyZoomControlsDemo.this.size = size + 2;
    // 更改文字大小
    MyZoomControlsDemo.this.text.setTextSize(size);
    }
    }

    private class OnZoomOutClickListenerImpl implements OnClickListener {

    @Override
    public void onClick(View view) {
    // 更改文字大小
    MyZoomControlsDemo.this.size = size - 2;
    // 更改文字大小
    MyZoomControlsDemo.this.text.setTextSize(size);
    }
    }
    }

  • 相关阅读:
    List<T>和ObservableCollection<T>的相互转换
    MySQL Cannot add or update a child row: a foreign key constraint fails
    Genymotion常见问题解决方案
    关于Socket的建立及连接
    在WPF中引用WinForm的控件
    WCF调试日志
    WebSocket简介
    关于依赖注入和依赖属性
    ASP.NET MVC 学习笔记1 Talk about controller & route
    【转】关于List排序的时效性
  • 原文地址:https://www.cnblogs.com/androidsj/p/2379402.html
Copyright © 2020-2023  润新知