拖动条:

布局文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@+id/gridView"    android:orientation="vertical"    android:layout_width="fill_parent"    android:layout_height="fill_parent" >    <EditText        android:id="@+id/font"        android:layout_width="match_parent"        android:layout_height="300dp"        android:ems="10"        android:lines="5"        android:text="看我大小,别翻眼..."        android:inputType="textMultiLine" >        <requestFocus />    </EditText>        <SeekBar         android:id="@+id/seekBar"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:max="100"        android:scrollbarStyle="insideOverlay"        android:progress="1"        /></LinearLayout>



主程序入口:
package com.example.advancedview;import android.app.Activity;import android.os.Bundle;import android.widget.EditText;import android.widget.SeekBar;import android.widget.Toast;import android.widget.SeekBar.OnSeekBarChangeListener;/** * SeekBar 功能演示, 拖动来改变字体的大小 * @author Administrator * */public class SeekBarActivity extends Activity {//声明变量private SeekBar seekBar;private EditText font;protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.seek_bar_layout);font = (EditText) findViewById(R.id.font);seekBar = (SeekBar) findViewById(R.id.seekBar);seekBar.setOnSeekBarChangeListener(seekListerner);}// 拖动条事件private OnSeekBarChangeListener seekListerner = new OnSeekBarChangeListener() {// 拖动条停止执行public void onStopTrackingTouch(SeekBar seekBar) {Toast.makeText(SeekBarActivity.this, "停止了:"+seekBar.getProgress(), 1000).show();}// 开始执行public void onStartTrackingTouch(SeekBar seekBar) {Toast.makeText(SeekBarActivity.this, "开始了:"+seekBar.getProgress(), 1000).show();}// 拖动中public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) {font.setTextSize(progress); // 改变字体的大小}};}

更多相关文章

  1. c#中Noto Sans字体支持韩文的实例教程
  2. Asp.NET控制文件上传的大小方法(超简单)_实用技巧
  3. c语言怎么比较两个数的大小
  4. C语言比较三个数大小
  5. c++大小写字母转换的思路有几种?
  6. c语言中如何让3个数按大小输出?
  7. c 语言怎么实现三个数大小排序
  8. c语言用什么函数来比较字符串大小?
  9. c语言大小写字母怎么转化?

随机推荐

  1. Python之错误异常和文件处理
  2. 在java中调用python方法
  3. Python知识点整理(基础篇)
  4. python 之 logger日志 字典配置文件
  5. python import的一些问题
  6. Python使用pandas对数据进行差分运算
  7. Python pyexcelerate库将多个工作表写入
  8. python 中 unicode原样转成str, unicode-
  9. python2和python3的区别
  10. 对numpy数组的每n个元素求平均值