<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);
怎么解决这个问题?似乎所有的事情都运转正常,但给出了这个错误…如果任何人可以请求帮助
解决方法BottomSheetBehavior
是 An interaction behavior plugin for a child vIEw of CoordinatorLayout to make it work as a bottom sheet.
目前,您的底层表nestedScrollVIEw是linearLayout的子项.所以只需完全删除最外面的linearLayout.
<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: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> <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>
但是现在你在尝试实现的底页上遇到了一些问题.首先,不应将wrap_content与滚动视图一起使用.其次,您不应在滚动视图中使用列表视图,因为它正在实现自己的滚动.您可以通过仅将列表视图用作底部工作表来简化此 *** 作.
总结以上是内存溢出为你收集整理的android – BottomSheetBehavior不是CoordinatorLayout的子代全部内容,希望文章能够帮你解决android – BottomSheetBehavior不是CoordinatorLayout的子代所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)