1
的孩子,這是我的XML佈局名稱的SongList:BottomSheetBehavior不CoordinatorLayout
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/viewA"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.6"
android:background="@android:color/holo_purple"
android:orientation="horizontal"/>
<android.support.v4.widget.NestedScrollView
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/holo_blue_bright"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="308dp"
/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:clickable="true"
android:src="@drawable/personlog"
app:layout_anchor="@id/viewA"
app:layout_anchorGravity="bottom|center"/>
</android.support.design.widget.CoordinatorLayout>
,這是我的片段,其中包含此佈局:
public class SongList extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.songlist,container,false);
textView=(TextView)view.findViewById(R.id.txt);
View bottomSheet = view.findViewById(R.id.bottom_sheet);
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
bottomSheetBehavior.setPeekHeight(200);
return view;}
}
但是當午餐的應用程序給我這個錯誤:
java.lang.IllegalArgumentException: The view is not a child of CoordinatorLayout
從這一行:
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
如何解決這一問題?似乎所有的東西很好地工作,但給該錯誤......如果任何一個可以請幫助
那麼如何才能使這種佈局真正的方式?如果你有一些解決方案,請回答 – Erf
我添加NestedScrollView裏面CoordinatorLayout但仍然相同的問題 – Erf
可以理解你的觀點。如果你想幫助我,請回答我的問題,不要評論,然後告訴我哪裏的代碼必須改變到什麼或那樣的事情。 TNX – Erf