我有一个图片在左边,标题和副标题在中间,ImageButton在右边的ListView (这个按钮在右边没有任何空白处)。

<ListView
android:id="@+id/contacts"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:cacheColorHint="@android:color/transparent"
android:fastScrollEnabled="true"
android:scrollbarStyle="outsideInset"/>我已启用此ListView的快速滚动。当我尝试点击右边的ImageButton时,滚动条变成焦点,ListView开始滚动。我无法选择右边的按钮。请帮帮我。
发布于 2016-01-26 20:58:31
您需要重写ListView onInterceptTouchEvent 类及其方法。
public class CustomListView extends ListView {
public CustomListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
setFastScrollEnabled(false);
boolean possibleResult = super.onInterceptTouchEvent(ev);
setFastScrollEnabled(true);
boolean actualResult = super.onInterceptTouchEvent(ev);
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
return possibleResult && actualResult;
}
return super.onInterceptTouchEvent(ev);
}
}它看起来会像这样:

但是,您观察到的问题是预期的行为。
正确的解决方法是将填充添加到行的末尾。
以谷歌的PhoneBook应用为例:

正如你在这里看到的,单元格的大小小于屏幕宽度的100%。
我希望,这会有所帮助
https://stackoverflow.com/questions/35008505
复制相似问题