Can we disable page sliding in PagerSlidingTabStrip ? I am using PagerSlidingTabStrip where tabs are created dynamically in my example. On each fragment there are tow buttons
Chapter wise analysis
Rank wise analysis
What i want is when user click on Rank wise analysis Sliding should disable and tabs get hide and when click on Chapter wise analysis tabs should visible again and sliding should also enable. How to achieve this? Tabs hide and show is working properly but am not able to make slide disable.
Create a separate class which should extend ViewPager:
public class CustomViewPager extends ViewPager {
public CustomViewPager(Context context) {
super(context);
}
public CustomViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
#Override
public boolean onInterceptTouchEvent(MotionEvent event) {
// Never allow swiping to switch between pages
return false;
}
#Override
public boolean onTouchEvent(MotionEvent event) {
// Never allow swiping to switch between pages
return false;
}
}
And then use this viewPager to set in your xml file like this:
<com.packagename.CustomViewPager
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
Then in your activity, set your FragmentPagerAdapter to this viewPager:
mViewPager.setAdapter(YourFragmentPagerAdapter)
Extend ViewPager and override onInterceptTouchEvent() and onTouchEvent().
#Override
public boolean onInterceptTouchEvent(MotionEvent event) {
return false;
}
#Override
public boolean onTouchEvent(MotionEvent event) {
return false;
}
Here is my solution....
I make slight changes with my layout.Previously i had 2 buttons on each fragment.
Now i place that two button in parent activity.. here is my xml file.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="#+id/lintab"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<com.joyoflearning.utils.PagerSlidingTabStrip
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="48dip"
android:background="#drawable/background_tab" />
</LinearLayout>
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/lintab"
android:background="#drawable/background_tab"
tools:context=".TestAnalysisActivity" />
<LinearLayout
android:id="#+id/RankAnalysisFragment"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/linButtons"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="#+id/linButtons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/darkGray"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingTop="5dp" >
<Button
android:id="#+id/btnChapterWise"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:background="#drawable/btn_blue_bg"
android:drawableLeft="#drawable/checkbtn_icon"
android:drawablePadding="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Chapterwise"
android:textColor="#ffffff" />
<Button
android:id="#+id/btnRankWise"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:background="#drawable/btn_blue_bg"
android:drawableLeft="#drawable/uncheckbtn_icon"
android:drawablePadding="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Rankwise"
android:textColor="#ffffff" />
</LinearLayout>
Now click on ChapterWiseAnalysisbutton will hide LinerLayout having id RankAnalysisFragment and click on RankWiseAnalysis will hide Tabs,ViewPager and add a fragment to LinerLayout .
Related
I am creating a music player app the below are list of activities:
WelcomeActivity
SongsListActivity
MusicPlayActivity
SongsListActivity will display list of songs available, on click of item it will take you to MusicPlayActivity and which will trigger SongService which in turn play song in background.
The below is MusicPlayActivity
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:background="#drawable/background">
<include layout="#layout/musicpanel"></include>
</RelativeLayout>
The below code is for musicpanel which is included in MusicPlayActivity
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Play"
android:id="#+id/playPause"
android:layout_gravity="bottom"
android:layout_marginLeft="51dp"
android:layout_marginStart="51dp"
android:layout_alignTop="#+id/stop"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Stop"
android:id="#+id/stop"
android:layout_gravity="bottom"
android:layout_marginBottom="28dp"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/playPause"
android:layout_toEndOf="#+id/playPause"
android:layout_marginLeft="67dp"
android:layout_marginStart="67dp" />
</RelativeLayout>
If the user click back button from MusicPlayActivity we need to display SongListActivity so here I want to display musicpanel.
My question is what is the best practice to create musicpanel?
Right now I am including it in xml but on each activity I need to set listeners for all components of musicpanel (like play, pause, next, previous) every time
Thanks in advance
You have several options:
Create a reusable widget. Make it use your player layout, setup listeners, etc. Then add it everywhere you need.
Move your player to a notification. It would be accessible from any place in your app. Notifications are quite simple and have to be in the notification area, but you can mix this solution with 1.
Move to fragments or views. Your player could be placed above main layout using FrameLayout or RelativeLayout. This is my preffered solution.
Move your player to a floating window. It's how the floating Facebook message's head is done. Tricky to do, but nice when done properly.
Usually it's done in 1/2 or 2/3 way as these combinations reduce code duplication and are quite easy to do.
I think its best for you.Using PageViwer .
1:make 2 fragments.
(1)firstActivity
(2)SecondActivity
2:Use PageViewer in your xml layout.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.8"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v4.view.ViewPager>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".2"
android:background="#android:color/black"
android:weightSum="3">
<ImageView
android:id="#+id/btn1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#android:drawable/ic_media_play" />
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#android:drawable/ic_media_pause" />
<ImageView
android:id="#+id/windowbtn"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#android:drawable/ic_menu_revert" />
</LinearLayout>
Here is viewPager Instance in your Main Activity.
viewPager = (ViewPager) findViewById(R.id.pager);
// viewPager.setPageTransformer(true, new VerticalPageTransformer());
mAdapter = new MultiPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(mAdapter);
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
#Override
public void onPageSelected(int position) {
}
#Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
}
#Override
public void onPageScrollStateChanged(int arg0) {
}
});
viewPager.setOnTouchListener(new View.OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
viewPager.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});
}
and here is Multipager adapter
public class MultiPagerAdapter extends FragmentPagerAdapter {
public MultiPagerAdapter(FragmentManager fm) {
super(fm);
}
#Override
public Fragment getItem(int index) {
switch (index) {
case 0:
// Top Rated fragment activity
return new FirstFragment();
case 1:
// Games fragment activity
return new SecFragment();
}
return null;
}
#Override
public int getCount() {
// get item count - equal to number of tabs
return 2;
}
}
I am implementing a RecyclerView inside a ScrollView. In order to have only one scrolling behaviour on the entire page I implement a NonScrollRecyclerView version. The implementation is as follows:
public class NonScrollRecyclerView extends RecyclerView {
public NonScrollRecyclerView(Context context) { super(context); }
public NonScrollRecyclerView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public NonScrollRecyclerView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
#Override
public boolean dispatchTouchEvent(MotionEvent ev){
if(ev.getAction() == MotionEvent.ACTION_MOVE)
return true;
return super.dispatchTouchEvent(ev);
}
}
Once i update my build and target settings to SDK 23, I have trouble scrolling the page which contains the NonScrollRecyclerView. The specific problem is that the page scrolls OK until i reach the recycler view portion and once i scroll onto this view I am unable to scroll anymore, either up or down.
I DONOT face this problem with SDK 22 and below
My xml is as follows:
XML #layout/rv contains the recycler view
<ScrollView 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:background="#color/background_gray">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/background_gray"
android:orientation="vertical">
<include
layout="#layout/row_mall_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/cv_mall_header"
android:layout_marginTop="8dp"/>
<include
layout="#layout/row_mall_shops"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/cv_mall_shops"
android:layout_marginTop="8dp"/>
<include
layout="#layout/row_mall_coupons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/cv_mall_coupons"
android:layout_marginTop="8dp"/>
<include
layout="#layout/rv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/cv_mall_feeds"
android:layout_marginTop="8dp"/>
</LinearLayout>
</ScrollView>
XML - #layout/rv
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background_gray"
android:id="#+id/ll_mall_feeds">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:paddingTop="6dp"
android:paddingBottom="6dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tv_feedcount"
android:textColor="#color/semi_theme_blue"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="12dp"
android:layout_centerVertical="true" />
</RelativeLayout>
<com.project.ui.NonScrollRecyclerView
android:id="#+id/nrv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#android:color/transparent"
android:listSelector="#android:color/transparent" />
</LinearLayout>
RecyclerView and ListView are not recommended inside a ScrollView because elements hights are not calculated when rendering the ScrollView. This means, your adapter might not be populated when the ScrollView is shown and later when the RecyclerView is notified about data changes (for instance when you initialize your adapter), there's not way to recalculate the elements heights.
It's really a pain in the neck because you have to try to calculate the elements heights and it's never accurate, so you will have discrepancies when showing a ListView or a RecyclerView inside a ScrollView. Some examples of how to calculate the elements heights can be checked here and here.
My advice is to turn your RecyclerView into a LinearLayout and add elements programmatically, so you emulates the ListView or RecyclerView behaviour:
LinearLayout layout = (LinearLayout) rootView.findViewById(R.id.files);
layout.removeAllViews();
for (int i = 0; i < fileAdapter.getCount(); i++) {
final View item = fileAdapter.getView(i, null, null);
item.setClickable(true);
item.setId(i);
item.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
fileContentRowPosition = v.getId();
# Your click action here
}
});
layout.addView(item);
}
Here its the XML with the files definition:
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent">
...
<LinearLayout
android:id="#+id/files"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
The whole java code can be checked here and the whole Layout here.
On the other hand, if you still want to continue with your implementation, and regarding your issue, you can check this article about Handling Scrollable Controls in Scrollview
Best regards,
For only one scrolling in the entire page you can use NestedScrollView instead of ScrollView and set recyclerView.setNestedScrollingEnabled(false);
I have a ScrollView. One of its children is a ListView. Both scrolling in the same direction. How do I get both of them to respond to scroll events? And then when the end of the ListView is reached for the event to go to the parent ScrollView so the ScrollView may scroll?
xml layout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
...
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
...
android:orientation="vertical"
>
<LinearLayout
android:id="#+id/..."
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal">
...
</LinearLayout>
<android.support.v4.view.ViewPager
.../>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="#dimen/pad_half"
>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
</LinearLayout>
</LinearLayout>
</ScrollView>
My ListView actually goes inside the ViewPager. The design is such that about three items in the ListView is visible, and user is able to scroll to see other items. In the meantime, the views above and below the ViewPager are visible. Again, it's a ViewPager: it has other pages than the ListView in question.
You Should not have a listview within a ScrollView.
But you can have a custom class and use that to accomplish A Listview with in a ScrollView.
Try the following code
first make a custom ScrollView Class.
public class VerticalScrollview extends ScrollView{
public VerticalScrollview(Context context) {
super(context);
}
public VerticalScrollview(Context context, AttributeSet attrs) {
super(context, attrs);
}
public VerticalScrollview(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
#Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
final int action = ev.getAction();
switch (action)
{
case MotionEvent.ACTION_DOWN:
super.onTouchEvent(ev);
break;
case MotionEvent.ACTION_MOVE:
return false; // redirect MotionEvents to ourself
case MotionEvent.ACTION_CANCEL:
super.onTouchEvent(ev);
break;
case MotionEvent.ACTION_UP:
return false;
default: break;
}
return false;
}
#Override
public boolean onTouchEvent(MotionEvent ev) {
super.onTouchEvent(ev);
return true;
}
}
Then use this class for you layout
<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:background="#android:color/white"
android:orientation="vertical" >
<com.gui.today.VerticalScrollview
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ProgressBar
android:id="#+id/progressBar3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal" />
<TextView
android:id="#+id/empty_calender"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="#string/empty_calender"
android:textColor="#ffffff"
android:visibility="gone" />
<ListView
android:id="#+id/listView2"
android:layout_width="fill_parent"
android:layout_height="150dp" >
</ListView>
</FrameLayout>
</LinearLayout>
</com.gui.today.VerticalScrollview>
I have a ScrollView
Get rid of it.
One of its children is a ListView
Put everything in the ListView, either using addHeaderView()/addFooterView(), my MergeAdapter, or something else along those lines.
You cant scroll a listview same direction as the scrollview. But if you have a horizontal scrollview you can scroll vertical with a listview.
you cannot add a ListView in a scroll View ,as list view also scolls and there would be a synchonization problem between listview scroll and scroll view scoll. You can make a CustomList View and add this method into it.
#Override public boolean onInterceptTouchEvent(MotionEvent ev)
{
/*
* Prevent parent controls from stealing our events once we've gotten a touch down
*/
if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) {
ViewParent p = getParent();
if (p != null) {
p.requestDisallowInterceptTouchEvent(true);
}
}
return false;
}
This is my XML layout - it's an info window.
i want that when the user clicks the #+id/fragment_info_relativelayout_content layout - the info window will be closed.
This is my XML:
<RelativeLayout
android:id="#+id/fragment_info_relativelayout_content"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:background="#drawable/background_info_window"
android:clickable="true" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:layout_margin="5dp" >
<!-- The info textView -->
<com.coapps.pico.NillanTextView
android:id="#+id/fragment_info_textview_info"
style="#style/text_shadow_black"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dp"
android:gravity="center"
android:text="Some Text "
android:textColor="#android:color/white"
app:isBold="true" />
</ScrollView>
<!-- Tap to close -->
<com.coapps.pico.NillanTextView
android:id="#+id/fragment_info_textview_tap_to_close"
style="#style/text_shadow_black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:gravity="right"
android:paddingRight="5dp"
android:text="#string/button_tap_to_close"
android:textColor="#android:color/white"
app:isBold="true" />
</RelativeLayout>
This is my code:
public InfoWindow(ViewGroup rootView)
{
this.container = rootView;
infoWindowView = LayoutInflater.from(rootView.getContext()).inflate(INFO_WINDOW_LAYOUT_ID, null);
//find info window's view
contentLayout = infoWindowView.findViewById(R.id.fragment_info_relativelayout_content);
contentLayout.setClickable(true);
contentLayout.setOnClickListener(this);
}
#Override
public void onClick(View v) {
//close the info window
close();
}
my problem is that the onClick method isn't being fired on every click on the layout...
it's weird since it does fire after clicking some clicks, or click at the bottom right on the textview...
any ideas ??
My suggestion, is that the ScrollView in the RelativeLayout handles all touch events, and don't let the RelativeLayout handle any touch events.
In this case, you should extend the ScrollView and make the onTouchEvent return false
#Override
public boolean onTouchEvent(MotionEvent ev) {
super.onTouchEvent(ev);
return false;
}
And the same to onInterceptTouchEvent
#Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
super.onInterceptTouchEvent(ev);
return false;
}
Just try it out and tell me what you got =)
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:
Similar Topic
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>
There is any good way to Lock Scrolling View in default way and use
SeekBar to do this??
Edit:
The solution seems to be much simpler, override the HorizontalScrollView class and pass the touch events through the view:
public class MyHScroll extends HorizontalScrollView {
// the constructors
#Override
public boolean onTouchEvent(MotionEvent ev) {
return false;
}
}
The use this class in the layout instead of the default HorizontallScrollView:
<com.your.package.MyHScroll
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>
</com.your.package.MyHScroll>
Try placing an overlay view on top of the HorizontalScrollView to "absorb" touch events without messing with the HorizontalScrollView itself:
<?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" />
<FrameLayout android:layout_width="wrap_content"
android:layout_height="fill_parent">
<HorizontalScrollView
android:id="#+id/hsv"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:scrollbars="none" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<!-- BUTTONS CODE - NOT IMPORTANT -->
</RelativeLayout>
</HorizontalScrollView>
<View android:id="#+id/overlay" android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</FrameLayout
</LinearLayout>
and then add a OnTouchListener for the overlay widget in the onCreate method to further block touch events:
findViewById(R.id.overlay).setOnTouchListener(new OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
The second problem is that my buttons (which have fill_parent height
parameter) are really small.
See the layout file above.