亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何消除 Android 應用程序頂部出現的額外間距?

如何消除 Android 應用程序頂部出現的額外間距?

慕森卡 2023-08-09 16:07:49
我正在為我的一門大學課程構建 Android 應用程序的主頁。我的小組正在使用 Android Studio。我已經有了原來的布局,但我在頂部有一個隨機的額外空間,上面寫著“歡迎”。我不知道如何擺脫頂部的隨機間距,它正在將我的其余對象向下推(報告列表在導航欄下方消失)這是我的fragment_home.xml<?xml version="1.0" encoding="utf-8"?><androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    android:layout_width="match_parent"    android:layout_height="match_parent">    <EditText        android:id="@+id/editText"        android:layout_width="365dp"        android:layout_height="wrap_content"        android:text="@string/home_welcome"        android:textAlignment="center"        android:textSize="20pt"        app:layout_constraintBottom_toTopOf="@+id/text_appts"        app:layout_constraintEnd_toEndOf="parent"        app:layout_constraintStart_toStartOf="parent"        app:layout_constraintTop_toTopOf="parent" />    <EditText        android:id="@+id/text_appts"        android:layout_width="365dp"        android:layout_height="55dp"        android:ems="10"        android:text="@string/title_appointments"        android:textSize="14pt"        app:layout_constraintBottom_toTopOf="@+id/recycler_appts"        app:layout_constraintEnd_toEndOf="parent"        app:layout_constraintStart_toStartOf="parent"        app:layout_constraintTop_toBottomOf="@+id/editText" />    <androidx.recyclerview.widget.RecyclerView        android:id="@+id/recycler_appts"        android:layout_width="360dp"        android:layout_height="125dp"        app:layout_constraintBottom_toTopOf="@+id/text_chats"        app:layout_constraintEnd_toEndOf="parent"        app:layout_constraintHorizontal_bias="0.484"        app:layout_constraintStart_toStartOf="parent"        app:layout_constraintTop_toBottomOf="@+id/text_appts"        app:layout_constraintVertical_bias="0.226" /></androidx.constraintlayout.widget.ConstraintLayout>
查看完整描述

2 回答

?
幕布斯6054654

TA貢獻1876條經驗 獲得超7個贊

在您的activity_main.xml文件中,嘗試刪除android:paddingTop="?attr/actionBarSize"ConstraintLayout 中的行,因為沒有 actionBar。



查看完整回答
反對 回復 2023-08-09
?
嚕嚕噠

TA貢獻1784條經驗 獲得超7個贊

在您的activity_main.xml中將'fragment'(nav_host_fragment)layout_width和layout_height更改為0dp。這是使用約束的正確形式。

 <fragment
    android:id="@+id/nav_host_fragment"
    android:name="androidx.navigation.fragment.NavHostFragment"
    android:layout_width="0dp"
    android:layout_height="0dp"
    app:defaultNavHost="true"
    app:layout_constraintBottom_toTopOf="@id/nav_view"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:navGraph="@navigation/mobile_navigation" />


查看完整回答
反對 回復 2023-08-09
  • 2 回答
  • 0 關注
  • 187 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號