xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/chuanzhang" android:id="@+id/iv"
/> <SeekBar android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/sbr"
android:max="255"
android:progress="255"
/> </LinearLayout>
java
package com.example.chenshuai.test322; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.ImageView; import android.widget.SeekBar; /** * Created by chenshuai on 2016/3/30. */ public class Tutou extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.touminggundonglayout); final ImageView imageView = (ImageView)findViewById(R.id.iv); final SeekBar sk_1 = (SeekBar)findViewById(R.id.sbr); sk_1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { imageView.setImageAlpha(progress); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); } }