cuốn sách gpt4 ai đã làm

Làm cách nào để mở BottomSheet từ trên xuống?

In lại Tác giả: Taklimakan Thời gian cập nhật: 2023-11-02 19:03:35 25 4
mua khóa gpt4 Nike

Tôi đang mở NestedScrollView trong ứng dụng của mình, hiện tại nó đang mở từ cuối màn hình. Làm cách nào để mở nó từ trên xuống?

Tôi đã thử loại bỏ các dòng sau:

app:layout_behavior="android.support.design.widget.BottomSheetBehavior"

Nhưng ứng dụng gặp sự cố với lỗi sau:

Chế độ xem không được liên kết với BottomSheetBehavior

Có cách nào để mở Bottom Sheet từ trên cùng màn hình không?

Đây là Hoạt động của tôi:

ViewPager mainViewPager;
riêng tư BottomSheetBehavior mBottomSheetBehavior;
trình chuyển đổi int = 1;
Xem menuPopupView;

@Ghi đè
khoảng trống được bảo vệ trênCreate(Gói đã lưuInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.workorder_selection_layout_with_fragment);
Thanh công cụ thanh công cụ = (Thanh công cụ) findViewById(R.id.toolbar);
setSupportActionBar(thanh công cụ);

...
....
...


filterButton = (Nút)
findViewById(R.id.filterButtonMainWorkorderSelection);
filterButton.setOnClickListener(new View.OnClickListener() {
@Ghi đè
khoảng trống công khai trênClick(Xem v) {

if (bộ chuyển đổi == 1) {
mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
bộ chuyển mạch = 2;
} khác {
mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
bộ chuyển đổi = 1;
}


}
});

/////////////////////////////////////////////////////////
//////////////Bảng mông///////////////////
/////////////////////////////////////////////////////////

Xem đáySheet = findViewById(R.id.bottom_sheet);

mBottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);


}

Đây là xml của tôi:



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"
ứng dụng:layout_behavior="@string/appbar_scrolling_view_behavior"
công cụ:context="apps.radwin.wintouch.activities.alignmentActivities.WorkordersSelectionActivity"
công cụ:showIn="@layout/app_bar_workorders_selection">

<>
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:theme="@style/AppTheme.AppBarOverlay">


android:id="@+id/thanh công cụ"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay">



<>
android:id="@+id/tabsLayoutWorkorderSelection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>



<>
android:id="@+id/workorderSelectionMainViewPagerContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />

<>
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_rabity="end|bottom"
android:src="@drawable/add_workorders_plus"
android:layout_marginLeft="@dimen/fab_margin"
android:layout_marginRight="@dimen/fab_margin"
android:layout_marginBottom="@dimen/fab_margin"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true" />



xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<>
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="true"
android:background="#293339"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
>


android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toStartOf="@+id/fab">


...
...
...


<>
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_below="@+id/workorderFilterPopup_CompleteImage"
>














câu trả lời hay nhất

Tôi không chắc đây có phải là thứ bạn muốn không nhưng liên kết bên dưới dành cho phiên bản "cấp cao nhất" của BottomSheetBehavior.

https://github.com/ipuris/AndroidTopSheet/blob/master/library/src/main/java/com/github/techisfun/android/topsheet/TopSheetBehavior.java

Chứa mã hoàn chỉnh cho ứng dụng mẫu:https://github.com/ipuris/AndroidTopSheet

Sẽ TopSheetHành vi class vào dự án của bạn, sau đó bạn có thể thêm ứng dụng:layout_behavior giá trị thay đổi thành TopSheetHành vi thay vì Để sử dụng nó>android.support.design.widget.BottomSheetBehavior.

Đoạn mã trên là từ kho lưu trữ gốc có nguồn gốc, nhưng tôi đã sửa một số phụ thuộc thư viện cho phiên bản Android mới nhất (phiên bản cũ android.support Thư viện-> androidx thư viện).

(Có thể câu trả lời này đã quá muộn đối với @jernkuan, nhưng tôi hy vọng câu trả lời này có thể hữu ích cho các nhà phát triển khác.)

Giới thiệu về android - Làm cách nào để mở BottomSheet từ trên xuống? , chúng tôi đã tìm thấy một câu hỏi tương tự trên Stack Overflow: https://stackoverflow.com/questions/39510205/

25 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress