android - How to disable button looking "pressed" when Gallery slide is pressed? -
i have gallery. each slide has button inside.
i have custom layout i'm inflating slides.
attached click listener button , works well, gallery scrolls normally.
but when press on gallery outside of button, button pressed , turns blue. doesn't trigger onclicklistener of button. makes button pressed , don't want that.
tried setting listeners of gallery empty implementations no effect...
thanks in advance.
edit: attached empty click listener custom layout , button doesn't become blue anymore gallery doesn't scroll because event consumed. see can done...
found workaround this. it's horrible, works.
first of all, part of gallery's code responsible problem this:
public boolean ondown(motionevent e) { // kill existing fling/scroll mflingrunnable.stop(false); // item's view touched mdowntouchposition = pointtoposition((int) e.getx(), (int) e.gety()); if (mdowntouchposition >= 0) { mdowntouchview = getchildat(mdowntouchposition - mfirstposition); mdowntouchview.setpressed(true); } // reset multiple-scroll tracking state misfirstscroll = true; // must return true matching events down event. return true; } more line:
mdowntouchview.setpressed(true); here layout of slide pressed , default behaviour of setpressed of linearlayout dispatching childrens children pressed.
first tried making subclass of gallery , override ondown. if returned false , nothing else, worked slides got strange behaviour of jumping next slide when touched. because of line:
mflingrunnable.stop(false); which not executed. since variable private , related else in gallery class didn't find way use subclass. tried copying gallery code, didn't work, because uses lot of things have package access... etc.
so created subclass of linearlayout, overrides onsetpressed:
public class linearlayoutonsetpresseddonothing extends linearlayout { public linearlayoutonsetpresseddonothing(context context, attributeset attrs) { super(context, attrs); } @override public void setpressed(boolean pressed) { } } and use in layout instead of linearlayout:
<?xml version="1.0" encoding="utf-8"?> <com.test.linearlayoutonpressdonothing xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <!-- content --> </com.test.linearlayoutonpressdonothing> and well, works.
Comments
Post a Comment