Professional Documents
Culture Documents
Project : ColorMixer
<TextView
android:id = "@+id/color"
android:layout_width = "200dip"
android:layout_height = "200dip"
android:background = "#353535" >
</TextView>
<SeekBar
android:id = "@+id/red"
android:layout_width = "270dip"
android:layout_height = "wrap_content"
android:layout_marginTop = "30dip"
android:max = "255" >
</SeekBar>
<SeekBar
android:id = "@+id/green"
android:layout_width = "270dip"
android:layout_height = "wrap_content"
android:layout_marginTop = "10dip"
android:max = "255" >
</SeekBar>
<SeekBar
android:id = "@+id/blue"
android:layout_width = "270dip"
android:layout_height = "wrap_content"
android:layout_marginTop = "10dip"
android:max = "255" >
</SeekBar>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity = "center" >
<TextView
android:id = "@+id/color"
android:layout_width = "200dip"
android:layout_height = "200dip"
android:background = "#353535" >
</TextView>
<SeekBar>
android:id = "@+id/red"
android:layout_width = "270dip"
android:layout_height = "wrap_content"
android:layout_marginTop = "30dip" >
</SeekBar>
<SeekBar
android:id = "@+id/blue"
android:layout_width = "270dip"
android:layout_height = "wrap_content"
android:layout_marginTop = "10dip"
android:max = "255" >
</SeekBar>
color = (TextView)findViewById(R.id.color);
red = (SeekBar)findViewById(R.id.red);
red.setOnSeekBarChangeListener(onSlide);
green = (SeekBar)findViewById(R.id.green);
green.setOnSeekBarChangeListener(onSlide);
blue = (SeekBar)findViewById(R.id.blue);
blue.setOnSeekBarChangeListener(onSlide);
color = (TextView)findViewById(R.id.color);
red = (SeekBar)findViewById(R.id.red);
red.setOnSeekBarChangeListener(onSlide);
green = (SeekBar)findViewById(R.id.green);
green.setOnSeekBarChangeListener(onSlide);
blue = (SeekBar)findViewById(R.id.blue);
blue.setOnSeekBarChangeListener(onSlide);
Code Java ฟังก์ชัน onSlide สําหรับ เหตุการณ์ การ เลื่อน Tab บน SeekBar
วิธีการ
1. เอาค่าจาก SeekBar แต่ละตัว มากําหนดค่าสี จะได้ว่า
2. เอาค่าสีที่ที่ได้ มากําหนดสี ให้กับ TextView จะได้ว่า
drbomkung@gmail.com