问题描述
edit 1:recyclerview 有一个固定的尺寸(300x500dp),这是因为我想检查覆盖是应用于 RecyclerView 还是整个 ViewGroup
我面临着片段和布局的问题,基本上我的应用程序使用子片段; 这是粗略的层次结构:
Activity
|-> FrameLayout (MainFragment,RootView: CoordinatorLayout)
|-> FrameLayout (ChildFragment,RootView: RelativeLayout)
| |-> RecyclerView
|-> LinearLayout (CustomSearchView)
| |-> CardView
|-> BottomAppBar
| |-> BottomNavigationView
|-> FloatingActionButton
这是代码的要点:https://gist.github.com/AwaisKing/12df079991558257307f40c8fa6a7d2d
我正在尝试 replace
和 addToBackStack
一个片段,但是每当我这样做时,它都会在 RecyclerView
我曾尝试将 background
添加到布局和视图中,但我没有运气。
希望有人能帮我解决这个问题
解决方法
有些地方你使用了 CoordinatorLayout,这基本上是一个 FrameLayout,所以如果你没有正确配置它,视图就会被覆盖。一目了然,它们是frag_main.xml
、int_frag_search.xml
还有一点,我认为你应该只在真正需要时才使用子片段
,感谢 @dominicoder 为我提供了解决这个问题的方向! comment #120480134
有一个属性 android:defaultFocusHighlightEnabled
我所要做的就是将它设置为 false