簡體   English   中英

如何從android的Bottom表中刪除頂部填充?

[英]How to remove top padding from Bottom sheet in android?

我曾嘗試在底部工作表協調器布局上設置 padding = 0。 如何從android中的bottomsheet中刪除頂部填充?

在此處輸入圖片說明

我想我已經得到了答案。 只需要從android:fitsSystemWindows="true"刪除android:fitsSystemWindows="true" ,即LinearLayout。 以防萬一我把xml代碼放在下面。

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:id="@+id/coordinatorLayout"
    tools:context=".MainActivity">

    <include layout="@layout/content_main" />


    <LinearLayout android:layout_width="match_parent"
        android:layout_height="wrap_content"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:orientation="horizontal"
        app:behavior_hideable="true"
        app:behavior_peekHeight="0dp"
        android:id="@+id/bottom_sheet"
        android:background="@android:color/holo_orange_light"
        app:layout_behavior="@string/bottom_sheet_behavior" 
        xmlns:android="http://schemas.android.com/apk/res/android">

        <ImageView
            android:layout_weight="1"
            android:layout_margin="@dimen/five"
            android:padding="@dimen/ten"
            android:src="@drawable/ic_photo_camera"
            android:layout_width="@dimen/fifty"
            android:layout_height="@dimen/fifty" />

        <ImageView
            android:layout_weight="1"
            android:layout_margin="@dimen/five"
            android:padding="@dimen/ten"
            android:src="@drawable/ic_image_gallery"
            android:layout_width="@dimen/fifty"
            android:layout_height="@dimen/fifty" />

        <ImageView
            android:layout_weight="1"
            android:layout_margin="@dimen/five"
            android:padding="@dimen/ten"
            android:src="@drawable/ic_video_camera"
            android:layout_width="@dimen/fifty"
            android:layout_height="@dimen/fifty" />

        <ImageView
            android:layout_weight="1"
            android:layout_margin="@dimen/five"
            android:padding="@dimen/ten"
            android:src="@drawable/ic_video_camera"
            android:layout_width="@dimen/fifty"
            android:layout_height="@dimen/fifty" />


    </LinearLayout>
</android.support.design.widget.CoordinatorLayout>

僅供我使用,我使用了不同的 drawable,您需要將其改回原來的。

我希望它有幫助!

您可以為底部工作表制作自定義視圖並在其中放置空格和邊距

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM