码迷,mamicode.com
首页 > 移动开发 > 详细

Android——进度条控制图片透明度

时间:2016-03-31 01:41:05      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:

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" />

</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) {


            }
        });
    }
}

技术分享

Android——进度条控制图片透明度

标签:

原文地址:http://www.cnblogs.com/Chenshuai7/p/5339527.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!