android - 在谷歌地图中实现 UI 组件,如 imageviews、recyclerviews安卓中的标签
问题描述
我正在实施谷歌地图,我想改变我的 xml 代码
从
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/_10sdp" android:layout_marginRight="@dimen/_10sdp" android:gravity="center" android:orientation="horizontal"> <ImageView android:id="@+id/MapCenter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@id/rvMap" android:layout_centerInParent="true" android:src="@drawable/map_center" /> <androidx.recyclerview.widget.RecyclerView android:id="@+id/rvMap" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="@dimen/_40sdp" /> </RelativeLayout>
至
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/_10sdp" android:layout_marginRight="@dimen/_10sdp" android:gravity="center" android:orientation="horizontal"> <ImageView android:id="@+id/MapCenter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@id/rvMap" android:layout_centerInParent="true" android:src="@drawable/map_center" /> <androidx.recyclerview.widget.RecyclerView android:id="@+id/rvMap" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="@dimen/_40sdp" /> </fragment>
当我更改为 Fragment 时,它没有正确显示内部组件,请告诉我如何在 Fragment 中使用 Ui 组件。
解决方案
您的 LinearLayout 小部件未关闭,请执行此操作
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/_10sdp"
android:layout_marginRight="@dimen/_10sdp"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/MapCenter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/rvMap"
android:layout_centerInParent="true"
android:src="@drawable/map_center" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvMap"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/_40sdp" />
</LinearLayout>
推荐阅读
- ruby-on-rails - 如何使用 Ruby 获取网站 (url) cookie 列表
- react-native - 反应原生 - 缺少srcipt:ios
- zendesk - Zendesk Chat 小部件状态检查
- binding - 在 xamarin 中为 SuperPoweredSDK 创建绑定包装器?
- scala - 从列表中搜索数据框以及在 Scala 的新列中找到的所有元素
- c# - 切换事件委托
- python - 需要加入代码才能获得所需的输出
- python - 当文件在 pytest 中可用时如何测试 FileNotFound 异常
- javascript - 使用 1 个按钮切换显示/隐藏 Google 标记
- python - 如何记录 Jupyter 笔记本输入以进行审计?