Android 工具栏下的片段

Android 工具栏下的片段,android,xml,android-fragments,toolbar,Android,Xml,Android Fragments,Toolbar,我以前从未在我的项目中使用过menu+fab。因此,我制作了3个选项卡片段,所有3个都显示listview,但我的片段放在工具栏下 下面是代码片段.xml <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://sc

我以前从未在我的项目中使用过menu+fab。因此,我制作了3个选项卡片段,所有3个都显示listview,但我的片段放在工具栏下

下面是代码片段.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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">

<TextView
    android:id="@+id/heading"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="14dp"
    android:paddingTop="16dp"
    android:text="VEHICLES REQUESTED"
    android:textColor="#88bf40"
    android:textStyle="bold"/>

<ListView
    android:id="@+id/vehicle_LV"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

</android.support.constraint.ConstraintLayout>


我想这个属性会对你有所帮助

布局图_约束图_toBottomOf

用法:

   <android.support.v4.view.ViewPager
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_constraintTop_toBottomOf="@+id/toolbar"
    android:id="@+id/viewPager"/>

尝试将此行添加到您的
AppBarLayout

android:layout_gravity="bottom"

这是为所有其他正在寻找相同问题答案的人准备的

所以问题是我的主题默认设置为无操作栏。 所以我用动作条把它改成了主题

下面是我添加到xml中的代码

android:theme="@style/AppTheme"
下面是我在styles.xml文件中添加的代码

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

@颜色/原色
@颜色/原色暗
@颜色/颜色重音

有什么问题吗?我想我误解了,我的listView在我的工具栏下面,我想原因是它的视图中没有任何工具栏。所以你的工具栏和选项卡必须合并?是的,它们是?有什么问题吗?你检查过我的答案吗?回答你自己的问题很好!然后,您需要将此答案标记为已接受的答案以结束问题;)哦,谢谢你让我知道D
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>