Scrolling a Gallery with buttons <p>I have a Gallery whose Adapter creates several LinearLayout instances. Those linear layout instances have buttons, however, and when someone clicks the buttons, they can't drag the gallery.</p> <p>My idea is having a menu that the user can scroll through. The kind of thing that would normally be done with a ScrollView, but because I want the scrolled view to 'Snap' to the current button pages, a Gallery works better.</p> <p>This question is similar to this one: <a href="http://stackoverflow.com/questions/7192417/android-gallery-of-linearlayouts">Android gallery of LinearLayouts</a></p> <p>However, while I've fixed the 'buttons appear clicked' when dragging issue, I can't seem to make it work like a ScrollView does, by having the buttons work as part of the dragging area.</p> <p>Any hints?</p> <p>Not sure if the code is relevant, but here it is.</p> <p>Layout that contains the gallery:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;Gallery android:id="@+id/gallery" android:layout_width="match_parent" android:layout_height="wrap_content" android:fadingEdge="none" android:spacing="0dp"/&gt; &lt;/FrameLayout&gt; </code></pre> <p>The test activity that populates the gallery:</p> <pre><code>import com.zehfernando.display.widgets.ZGallery; public class ScrollTestActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.scrolltest); Gallery gallery = (Gallery) findViewById(R.id.gallery); gallery.setAdapter(new LayoutAdapter(this)); } public class LayoutAdapter extends BaseAdapter { private Context mContext; public LayoutAdapter(Context c) { mContext = c; } public int getCount() { return 3; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater vi = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = vi.inflate(R.layout.scrolllayout, null); v.setMinimumWidth(getWindowManager().getDefaultDisplay().getWidth()); return v; } } } </code></pre> <p>The layout for the frames that go inside the gallery:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;com.zehfernando.display.widgets.ScrollableLinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;Button android:id="@+id/buttonRegister" android:layout_width="200dp" android:layout_height="72dp" android:text="REGISTER"/&gt; &lt;Button android:id="@+id/buttonUnregister" android:layout_width="match_parent" android:layout_height="72dp" android:text="UNREGISTER" /&gt; &lt;/com.zehfernando.display.widgets.ScrollableLinearLayout&gt; </code></pre> <p>"ScrollableLinearLayout" is just my class that extends LinearLayout to override onPressed.</p>