我正在android中工作。我想在我的應用程序中添加seekbar的功能。Seekbar.getRight()和Seekbar.getLeft()返回0
這是我的xml文件: -
<SeekBar
android:id="@+id/ProgressBar01"
android:layout_width="fill_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_height="60dp"
android:layout_below="@+id/incentives_textViewBottemLeft"
android:max="10"
android:progressDrawable="@drawable/incentive_progress"
android:secondaryProgress="0"
android:thumb="@drawable/incentives_progress_pin" />
And this is my java code related to this seek bar.
mSkbSample = (SeekBar)findViewById(R.id.ProgressBar01);
v1 = (TextView)findViewById(R.id.incentives_textViewAbove_process_pin);
v1.setText(String.valueOf(progress).toCharArray(), 0, String.valueOf(progress).length());
mSkbSample.setProgress(progress);
int xPos = ((mSkbSample.getRight() - mSkbSample.getLeft()) * mSkbSample.getProgress())/mSkbSample.getMax();
v1.setPadding(xPos,0,0,0);
我試圖打印mSkbSample.getRight()
和mSkbSample.getLeft()
,這總是返回零。 幫助我找出我做了什麼錯誤。
你在做onCreate嗎? – blessenm
是的,先生我在onCreate這樣做。 –