zoukankan      html  css  js  c++  java
  • 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;
        }
    
    }
  • 相关阅读:
    HDU 2853 (KM最大匹配)
    HDU 2852 (树状数组+无序第K小)
    HDU 2851 (最短路)
    HDU 2846 (AC自动机+多文本匹配)
    MyBatis使用示例
    Hessian示例:Java和C#通信
    SQL Server2005配置同步复制
    【问】如何应对关系型数据库中列的不断增加
    Prolog学习:数独和八皇后问题
    Prolog学习:基本概念
  • 原文地址:https://www.cnblogs.com/panjiangfy/p/android3.html
Copyright © 2011-2022 走看看