所以,长话短说。我正在尝试在Android Studio中创建一个应用程序,该应用程序具有一个从左侧滑动的“导航”视图,然后是一个具有三个选项卡(Medidas,Registros和Graficos)的TabLayout。问题在于,添加navigationView之后,我无法再在三个选项卡中看到文本。
我不是布局专家,所以在设置xml标签时遇到问题。参见下面的代码:
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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:id="@+id/drawer_layout"
android:fitsSystemWindows="true"
android:layout_height="match_parent"
tools:context=".PantallaDatos"
tools:openDrawer="start">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<View
android:layout_width="match_parent"
android:layout_height="3dp"
android:background="@color/colorDivider"
app:layout_constraintBottom_toBottomOf="@id/tabLayout" />
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
app:layout_constraintTop_toTopOf="parent"
app:tabIndicatorHeight="3dp"
app:tabMode="fixed"
app:tabPaddingBottom="8dp"
app:tabPaddingTop="15dp" />
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/tabLayout" />
</LinearLayout>
<com.google.android.material.navigation.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:id="@+id/nav_view"
app:headerLayout="@layout/nav_header"
app:menu="@menu/drawer_menu"/>
您可能会在蓝图中看到,我有很多标签彼此叠加。我认为这导致我无法正确查看标签布局。有人可以帮我设置标签吗?或者也许有更好的方法来完成所有这些工作。
提前谢谢您