我想创建bottomsheetdialog以从地图中选择一个地方。但是在我的设计中,google maps顶部是角形的。如果我将SupportMapFragment背景设为父级,顶部是角形的SupportMapFragmnet矩形。
<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>
那么如何像我给定的静态高度那样设置底片高度
答案 0 :(得分:2)
将添加扩展功能以应用于任何视图。否则,您可以提取方法的内容并单独应用。将此应用到您的ROOT布局。
/**
* 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
}