Я создаю домашнюю страницу для приложения Android для одного из моих занятий в колледже.Моя группа использует Android Studio.У меня есть макет, которым я был, но у меня есть это случайное дополнительное пространство вверху, где написано «Добро пожаловать».
Я не могу понять,как избавиться от этого случайного интервала вверху, и он толкает остальные мои объекты вниз (список отчетов исчезает под панелью навигации)
Вот мой фрагмент_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" />
<EditText
android:id="@+id/text_chats"
android:layout_width="365dp"
android:layout_height="55dp"
android:ems="10"
android:text="@string/title_chats"
android:textSize="14pt"
app:layout_constraintBottom_toTopOf="@+id/recycler_chats"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/recycler_appts" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_chats"
android:layout_width="360dp"
android:layout_height="125dp"
app:layout_constraintBottom_toTopOf="@+id/text_reports"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.484"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text_chats"
app:layout_constraintVertical_bias="0.226" />
<EditText
android:id="@+id/text_reports"
android:layout_width="365dp"
android:layout_height="55dp"
android:ems="10"
android:text="@string/title_reports"
android:textSize="14pt"
app:layout_constraintBottom_toTopOf="@+id/recycler_reports"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/recycler_chats" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_reports"
android:layout_width="360dp"
android:layout_height="125dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.424"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text_reports"
app:layout_constraintVertical_bias="0.226" />
</androidx.constraintlayout.widget.ConstraintLayout>
Вот мойHomeFragment.java
package com.example.telemedicine.ui.home;
import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.telemedicine.R;
import com.example.telemedicine.ui.utilities.RecyclerItem;
public class HomeFragment extends Fragment {
private HomeViewModel homeViewModel;
private RecyclerView recyclerView_appt, recyclerView_chat, recyclerView_report;
private RecyclerView.Adapter mAdapter_appt, mAdapter_chat, mAdapter_report;
private RecyclerView.LayoutManager layoutManager_appt, layoutManager_chat, layoutManager_report;
private String[] apptData = {"Physical - 9/29 @ 10:00am", "Vaccination - 10/4 @ 1:30pm", "Check-Up - 10/19 @ 9:00am"};
private String[] chatData = {"Dr. Jane Smith", "Dr. Hayden Lee", "Dr. Michael Dean"};
private String[] reportData = {"Blood Work 9/10", "Vaccination Summary 9/1", "Physical 8/23"};
//Activity activity = (Activity)getContext();
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
homeViewModel =
ViewModelProviders.of(this).get(HomeViewModel.class);
View root = inflater.inflate(R.layout.fragment_home, container, false);
final TextView textView = root.findViewById(R.id.editText);
homeViewModel.getText().observe(this, new Observer<String>() {
@Override
public void onChanged(@Nullable String s) {
textView.setText(s);
}
});
recyclerView_appt = (RecyclerView)root.findViewById(R.id.recycler_appts);
layoutManager_appt = new LinearLayoutManager(this.getActivity());
recyclerView_appt.setLayoutManager(layoutManager_appt);
mAdapter_appt = new RecyclerItem(apptData);
recyclerView_appt.setAdapter(mAdapter_appt);
recyclerView_chat = (RecyclerView)root.findViewById(R.id.recycler_chats);
layoutManager_chat = new LinearLayoutManager(this.getActivity());
recyclerView_chat.setLayoutManager(layoutManager_chat);
mAdapter_chat = new RecyclerItem(chatData);
recyclerView_chat.setAdapter(mAdapter_chat);
recyclerView_report = (RecyclerView)root.findViewById(R.id.recycler_reports);
layoutManager_report = new LinearLayoutManager(this.getActivity());
recyclerView_report.setLayoutManager(layoutManager_report);
mAdapter_report = new RecyclerItem(reportData);
recyclerView_report.setAdapter(mAdapter_report);
return root;
}
}
Вот мой HomeViewModel.java
package com.example.telemedicine.ui.home;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
public class HomeViewModel extends ViewModel {
private MutableLiveData<String> mText;
public HomeViewModel() {
mText = new MutableLiveData<>();
}
public LiveData<String> getText() {
return mText;
}
}
И мой activity_main.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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorBackground"
android:paddingTop="?attr/actionBarSize">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_nav_menu" />
<fragment
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
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" />
</androidx.constraintlayout.widget.ConstraintLayout>
Я не знаю, какие другие файлы включитьно, надеюсь, проблема в этих четырех файлах.Я пробовал так много вещей, чтобы избавиться от этого пробела, но я не могу понять, как избавиться от него.
Заранее спасибо !!