您的位置:首页 > 移动开发 > Android开发

Android 进度条改变图片透明度

2020-01-15 11:33 323 查看
1 <?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3     xmlns:tools="http://schemas.android.com/tools"
4     android:layout_width="match_parent"
5     android:layout_height="match_parent"
6     tools:context="com.example.administrator.jsq.MainActivity"
7     android:orientation="vertical">
8     <!--图片透明-->
9     <SeekBar
10         android:layout_width="match_parent"
11         android:layout_height="wrap_content"
12         android:max="250"
13         android:progress="0"
14         android:id="@+id/sar"/>
15     <ImageView
16         android:layout_width="wrap_content"
17         android:layout_height="wrap_content"
18         android:src="@drawable/f8"
19         android:id="@+id/tp"
20         />
21 </LinearLayout>
1 package com.example.administrator.jsq;
2
3 import android.media.Image;
4 import android.support.v7.app.AppCompatActivity;
5 import android.os.Bundle;
6 import android.util.Log;
7 import android.view.View;
8 import android.widget.ImageView;
9 import android.widget.SeekBar;
10
11 public class MainActivity extends AppCompatActivity {
12     SeekBar sar;
13     ImageView tp;
14
15     @Override
16     protected void onCreate(Bundle savedInstanceState) {
17         super.onCreate(savedInstanceState);
18         setContentView(R.layout.activity_main);
19         sar = (SeekBar)findViewById(R.id.sar);
20         tp = (ImageView)findViewById(R.id.tp);
21         tp.setImageAlpha(0);
22         sar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
23             @Override
24             public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
25                 tp.setImageAlpha(progress);
26             }
27
28             @Override
29             public void onStartTrackingTouch(SeekBar seekBar) {
30                 Log.e("TAG", "进度条开始拖动");
31             }
32
33             @Override
34             public void onStopTrackingTouch(SeekBar seekBar) {
35                 Log.e("TAG","进度条停止拖动");
36             }
37         });
38     }
39 }
1 <?xml version="1.0" encoding="utf-8"?>
2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3     package="com.example.administrator.jsq">
4
5     <application
6         android:allowBackup="true"
7         android:icon="@mipmap/ic_launcher"
8         android:label="@string/app_name"
9         android:supportsRtl="true"
10         android:theme="@style/AppTheme">
11         <activity android:name=".MainActivity">
12             <intent-filter>
13                 <action android:name="android.intent.action.MAIN" />
14                 <category android:name="android.intent.category.LAUNCHER" />
15             </intent-filter>
16         </activity>
17     </application>
18
19 </manifest>

 

转载于:https://www.cnblogs.com/TENOKAWA/p/5479144.html

  • 点赞
  • 收藏
  • 分享
  • 文章举报
banglun5623 发布了0 篇原创文章 · 获赞 0 · 访问量 188 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: