个人网站
拖动条改变图片的透明度
xml
资源方面,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; }}