[英]android layout elements going behind bottom navigation bar
我已經搜索過,但我沒有找到任何對我有用的東西。
我正在開發一個簡單的 android 應用程序。 我遇到的問題是特定手機默認底部導航欄后面的布局 go 中的內容。
所以我嘗試了兩部智能手機,第一部的布局符合預期,就是它的外觀Image1
在第二部智能手機中,該按鈕不可見,位於底部導航欄(不在我們的代碼中,是智能手機的默認欄)的后面。
更改布局以使其適合第二部智能手機后,它看起來像第一個Image2
這不是我需要的。 我該如何解決這個問題,以便我可以在每部智能手機中看到該應用程序,如 image.1?
這是片段。
<androidx.constraintlayout.widget.ConstraintLayout
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:id="@+id/frameLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".profile.Profile_photo_frag">
<GridView
android:id="@+id/gridView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/_45sdp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/add_photo"
android:layout_above="@id/add_photo"
android:columnWidth="90dp"
android:gravity="center"
android:horizontalSpacing="10dp"
android:numColumns="2"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp">
</GridView>
<Button
android:id="@+id/add_photo"
android:layout_width="match_parent"
android:layout_height="@dimen/_40sdp"
app:layout_constraintTop_toBottomOf="@id/gridView"
android:layout_marginBottom="@dimen/_1sdp"
android:text="Upload image" />
</androidx.constraintlayout.widget.ConstraintLayout>
編輯:這是選項卡片段的根布局
<androidx.constraintlayout.widget.ConstraintLayout
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">
<ImageView
android:id="@+id/profile_image"
android:layout_width="149dp"
android:layout_height="141dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="@drawable/add_img" />
<TextView
android:id="@+id/user_country"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="68dp"
android:text="Altro"
app:layout_constraintStart_toStartOf="@+id/user_name"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="160dp"
android:layout_marginLeft="160dp"
android:layout_marginTop="17dp"
android:layout_marginBottom="695dp"
android:text="Nome"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/user_mail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="96dp"
android:text="Mail"
android:textStyle="italic"
app:layout_constraintStart_toStartOf="@+id/user_country"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/edit_profile"
android:layout_width="57dp"
android:layout_height="52dp"
android:layout_marginTop="36dp"
android:layout_marginBottom="643dp"
android:background="#00F3F3F3"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="@+id/user_country"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="@drawable/ic_edit_black_24dp" />
<View
android:id="@+id/divider"
android:layout_width="409dp"
android:layout_height="1dp"
android:layout_marginTop="220dp"
android:background="#000000"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="149dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageButton
android:id="@+id/but_p_profile"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/left_border"
app:srcCompat="@drawable/ic_travel" />
<ImageButton
android:id="@+id/but_p_photo"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/left_border"
app:srcCompat="@drawable/ic_pictures" />
<ImageButton
android:id="@+id/but_p-posts"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/left_border"
app:srcCompat="@drawable/ic_ads" />
<ImageButton
android:id="@+id/imageButton16"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/left_border"
app:srcCompat="@drawable/ic_commerce" />
</LinearLayout>
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="61dp"
android:layout_marginTop="149dp"
app:layout_constraintTop_toTopOf="parent"
app:tabIndicatorColor="#9C27B0"
app:tabMode="fixed"
android:fitsSystemWindows="true">
<com.google.android.material.tabs.TabItem
android:id="@+id/first"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
<com.google.android.material.tabs.TabItem
android:id="@+id/second"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
<com.google.android.material.tabs.TabItem
android:id="@+id/third"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="" />
<com.google.android.material.tabs.TabItem
android:id="@+id/fourth"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="" />
</com.google.android.material.tabs.TabLayout>
<androidx.viewpager.widget.ViewPager
android:fitsSystemWindows="true"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="509dp"
android:layout_marginTop="220dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
</androidx.viewpager.widget.ViewPager>
</androidx.constraintlayout.widget.ConstraintLayout>
在您的 constraintLayout 添加 LinearLayout 然后設置您的 UI,但不使用邊距來放置 static 值。 您可以使用重量來管理您的塊。 需要一些幫助跟隨鏈接和堆棧溢出中可用的更多示例。
我希望它會幫助你!
當然這是您的視圖尋呼機高度和上邊距的問題。 您不應設置 static 邊距和高度,而是將視圖尋呼機的頂部與頂部視圖層次結構中最后一個視圖的底部對齊。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.