标签:
Layout文件代码:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.hanqi.testapp2.TestActivity5" android:orientation="vertical"> <SeekBar android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/seekBar" android:max="250" android:progress="0"/> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/niu" android:id="@+id/iv_1"/> </LinearLayout>
Activity代码:
package com.hanqi.testapp2; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.ImageView; import android.widget.SeekBar; public class TestActivity4 extends AppCompatActivity { SeekBar seekBar; ImageView iv_1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_test5); seekBar =(SeekBar)findViewById(R.id.seekBar); iv_1 =(ImageView)findViewById(R.id.iv_1); iv_1.setAlpha(0); seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { iv_1.setAlpha(progress); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); } }
标签:
原文地址:http://www.cnblogs.com/beens/p/5479149.html