çözüm böyle ListView
uzatmaktır:
düzeninizin dosyasında
bottom_sheet_view.xml
yılında Sonra
public class BottomSheetListView extends ListView {
public BottomSheetListView (Context context, AttributeSet p_attrs) {
super (context, p_attrs);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return true;
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (canScrollVertically(this)) {
getParent().requestDisallowInterceptTouchEvent(true);
}
return super.onTouchEvent(ev);
}
public boolean canScrollVertically (AbsListView view) {
boolean canScroll = false;
if (view !=null && view.getChildCount()> 0) {
boolean isOnTop = view.getFirstVisiblePosition() != 0 || view.getChildAt(0).getTop() != 0;
boolean isAllItemsVisible = isOnTop && view.getLastVisiblePosition() == view.getChildCount();
if (isOnTop || isAllItemsVisible) {
canScroll = true;
}
}
return canScroll;
}
}
: nihayet Sonra
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.mypackage.name.BottomSheetListView
android:id="@+id/listViewBtmSheet"
android:divider="@color/colorPrimary"
android:dividerHeight="1dp"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp" />
</LinearLayout>
, senin Activity
/Fragment
:
BottomSheetDialog dialog = new BottomSheetDialog(context);
dialog.setContentView(R.layout.bottom_sheet_view);
BottomSheetListView listView = (BottomSheetListView) dialog.findViewById(R.id.listViewBtmSheet);
// apply some adapter - add some data to listview
dialog.show();
Bu birsağlayacaktır, ListView
kaydırma ile tamamen çalışıyor. Eğer ListView
genişletmek istemiyorsanız
hey dostum, güzel çözüm, ancak liste öğeleri tıklanabilir değil, bunun için herhangi bir hack değil? – sUndeep
@sUndeep öğeleri benim için tıklanabilir. Liste öğesi düzeninde "ImageView" veya "Button" var mı? Eğer öyleyse, 'android: descendantFocusability = "blocksDescendants" 'list öğesi düzeninin –
kök elemanına eklemelisiniz, android yazmadan yaptım: descendantFocusability =" blocksDescendants ". Ama biraz daha iyileştirmeye ihtiyacı var. Ben yorum – sUndeep