Android-如何在CoordinatorLayout中添加TextView
有人能告诉我如何在选项卡布局/列表视图的底部添加文本视图吗 这里是主要活动,它承载选项卡片段Android-如何在CoordinatorLayout中添加TextView,android,android-layout,android-coordinatorlayout,Android,Android Layout,Android Coordinatorlayout,有人能告诉我如何在选项卡布局/列表视图的底部添加文本视图吗 这里是主要活动,它承载选项卡片段 <?xml version="1.0" encoding="utf-8"?> <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/a
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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"
tools:context=".ChecklistActivity">
<androidx.viewpager.widget.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/tabAppBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayoutView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:tabMode="scrollable" />
</com.google.android.material.appbar.AppBarLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
尝试使用文本视图锚定查看页面
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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"
tools:context=".ChecklistActivity">
<androidx.viewpager.widget.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_anchor="@id/myTextView"
app:layout_anchorGravity="top"
app:layout_dodgeInsetEdges="bottom"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/tabAppBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayoutView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:tabMode="scrollable" />
</com.google.android.material.appbar.AppBarLayout>
<TextView
android:id="@+id/myTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:layout_insetEdge="bottom"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
尝试使用TextView
锚定view\u寻呼机
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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"
tools:context=".ChecklistActivity">
<androidx.viewpager.widget.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_anchor="@id/myTextView"
app:layout_anchorGravity="top"
app:layout_dodgeInsetEdges="bottom"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/tabAppBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayoutView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:tabMode="scrollable" />
</com.google.android.material.appbar.AppBarLayout>
<TextView
android:id="@+id/myTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:layout_insetEdge="bottom"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
这确实将TextView放在了底部。但是,片段位于其后面,并且片段不会调整大小以允许TextView。因此文本视图覆盖了片段底部的数字和按钮。我们如何让片段考虑textview?您是否尝试了与我发布的完全相同的方法?它基本上是通过app:layout\u insetteges和app:layout\u insettege完成的,锚定相应的视图。我试过这个,它对我有效…谢谢。您是否更改了ViewPager的属性并不明显。我只关注文本视图。它现在看起来确实起作用了!!!太好了。除非我错过了其他的东西,否则这会导致另一个问题。它向上推选项卡片段,使其顶部隐藏且不可见-在TableLayout自身后面。因此,如果在可见时添加与TextViews高度相等的页边距,则会怎么样?这确实会将TextView置于底部。但是,片段位于其后面,并且片段不会调整大小以允许TextView。因此文本视图覆盖了片段底部的数字和按钮。我们如何让片段考虑textview?您是否尝试了与我发布的完全相同的方法?它基本上是通过app:layout\u insetteges和app:layout\u insettege完成的,锚定相应的视图。我试过这个,它对我有效…谢谢。您是否更改了ViewPager的属性并不明显。我只关注文本视图。它现在看起来确实起作用了!!!太好了。除非我错过了其他的东西,否则这会导致另一个问题。它向上推选项卡片段,使其顶部隐藏且不可见-在TableLayout自身后面。那么,如果将页边距添加到“查看”页面,使其在可见时与TextViews高度相等,该怎么办?