• android实例3:拖动条


    个人网站http://www.ravedonut.com/

    拖动条改变图片的透明度

    xml

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
         
        <ImageView 
            android:id="@+id/image"
            android:layout_width="fill_parent"
            android:layout_height="240px"
            android:src="@drawable/logo"
            />
        
        <SeekBar 
            android:id="@+id/seelbar"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:max="255"
            android:progress="255"
            android:thumb="@drawable/ic_launcher"
            />
         
    </LinearLayout>

    资源方面,SeeKBar的thumb时拖动条按钮的样式,

    activity:

    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Menu;
    import android.widget.ImageView;
    import android.widget.SeekBar;
    
    public class MainActivity extends Activity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            
            final ImageView image =(ImageView)findViewById(R.id.image);
            SeekBar seekbar = (SeekBar)findViewById(R.id.seelbar);
            
            seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                
                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {
                    // TODO Auto-generated method stub
                    
                }
                
                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {
                    // TODO Auto-generated method stub
                    
                }
                
                @Override
                public void onProgressChanged(SeekBar seekBar, int progress,
                        boolean fromUser) {
                    // TODO Auto-generated method stub
                    image.setAlpha(progress);
                }
            });
            
            
        }
    
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.main, menu);
            return true;
        }
    
    }
  • 相关阅读:
    C# Redis实战(四)
    C# Redis实战(三)
    C# Redis实战(二)
    C# Redis实战(一)
    C#连接内存数据库redis【1、Redis存读取数据】
    C#连接内存数据库redis【1、安装配置】
    c#根据配置文件反射
    内存数据库:Redis与Memcached的区别
    内存数据库:memcached与redis技术的对比试验
    【转】【涨姿势】支付宝怎么做风险控制?
  • 原文地址:https://www.cnblogs.com/panjiangfy/p/android3.html
Copyright © 2020-2023  润新知