android - 让谷歌地图走投无路
问题描述
我想创建bottomsheetdialog 用于从地图中选择一个地方。但是在我的设计中,谷歌地图顶部是角落。如果我让SupportMapFragment 背景的父级顶部角落SupportMapFragmnet rectangle.not 角落。有些人知道如何实现?
<RelativeLayout
android:id="@+id/root"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="570dp"
android:maxHeight="570dp"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="FragmentTagUsage" />
<LinearLayout
android:layout_marginTop="16dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:layout_marginLeft="34dp"
android:layout_marginRight="34dp"
app:cardCornerRadius="10dp"
android:layout_width="match_parent"
android:layout_height="40dp">
<EditText
android:id="@+id/edit_text_name"
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp"
android:textColorHint="@color/grey"
android:fontFamily="@font/poppins_semibold"
android:textSize="12sp"
android:textColor="@color/black"
android:background="@color/transparent"
android:hint="@string/set_name_to_place"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:importantForAutofill="no"
android:inputType="text" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_gravity="end"
android:id="@+id/card_view_my_location"
android:layout_margin="18dp"
android:layout_width="40dp"
android:layout_height="40dp"
app:cardCornerRadius="30dp"
app:cardElevation="4dp">
<ImageView
android:layout_gravity="center"
app:srcCompat="@drawable/ic_my_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:ignore="ContentDescription" />
</androidx.cardview.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/button_add"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="@dimen/basic_card_margin"
android:layout_marginRight="@dimen/basic_card_margin"
android:background="@drawable/background_button_selector"
android:text="@string/add"
android:textAllCaps="false"
android:textColor="@color/white" />
<View
android:background="@color/transparent"
android:layout_width="match_parent"
android:layout_height="35dp"/>
</LinearLayout>
</RelativeLayout>
那么我怎样才能像我给静态高度一样制作底片高度
解决方案
将添加一个扩展功能以应用于任何视图。否则,您可以提取方法的内容并单独应用。将此应用于您的根布局。
/**
* Rounds the top corners of the View
*/
fun View.setTopRoundedCorners(radius: Float) {
outlineProvider = object : ViewOutlineProvider() {
override fun getOutline(view: View, outline: Outline) {
outline.setRoundRect(
0, 0, view.width, (view.height + radius).toInt(), radius
)
}
}
clipToOutline = true
}
推荐阅读
- kubernetes - 清理 Kubernetes 工作
- javascript - 创建反应库的最佳方法
- reactjs - 如何将axios响应保存到变量并更新react js中的状态?
- botframework - Microsoft Teams - ms 团队机器人中的多选
- python - Flask-Session逻辑和JWT类似吗
- plotly - 无法在 div 子组件中追加
- c++ - 从“int”到“int*”CPP 的无效转换
- angular - 角数据表排序数字后缀(k,Mn,Bn)
- elasticsearch - Logstash 与 Elasticsearch:我正在使用 logstash 将数据摄取到 ES 索引中。但现在我希望logstash 24/7 运行
- swift - 阴影渲染不正确?迅速