I'm writting an application and it looks like this:
How you can see there is SeekBar on top and several buttons in HorizontalScrolView below. I would like to use SeekBar to scrolling buttons and this works fine now, but I can't turn off the default way to scroll View (draginng screen). I found similat topic on forum:
But the problem is, that this way locking whole ScrollView and I cant use it by seekBar and default way - maybe I'm doing something wrong (I did it the same like in the link and this not wort even if I have TRUE in mScrollable parameter). The second problem is that my buttons (which have fill_parent height parameter) are really small.
Question: There is any good way to Lock Scrolling View in default way and use SeekBar to do this??
My Code (default HorizontalScrollView):
public class MainActivity extends Activity implements SeekBar.OnSeekBarChangeListener {
static private String TAG = "MainActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
SeekBar seek = (SeekBar) findViewById(R.id.seekBar);
final HorizontalScrollView hsv = (HorizontalScrollView)findViewById(R.id.hsv);
seek.setMax(948);
seek.setProgress(474);
seek.setOnSeekBarChangeListener(this);
hsv.post(new Runnable() {
@Override
public void run() {
hsv.scrollTo(474, 0);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) {
HorizontalScrollView hsv = (HorizontalScrollView)findViewById(R.id.hsv);
hsv.scrollTo(progress, 0);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
Log.d(TAG, "Tracking on");
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
Log.d(TAG, "Tracking off");
}
activity_main:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#0A0A0A"
android:orientation="vertical" >
<SeekBar
android:id="@+id/seekBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<HorizontalScrollView
android:id="@+id/hsv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="none" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<!-- BUTTONS CODE - NOT IMPORTANT -->
</RelativeLayout>
</HorizontalScrollView>
</LinearLayout>