ich bin eine Anwendung, in der ich möchte die Aktivität eine bottomBar und jedes Element davon ein Fragment haben. Das erste Fragment sollte einen Viewpager haben. Alles funktioniert einwandfrei, außer dass TabLayout und Toolbar nicht dieselbe Höhe haben.Tablayout und Toolbar sind nicht auf der gleichen Höhe
Das Problem ist:
und meine Tätigkeit Layout ist:
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar_top" />
</android.support.design.widget.AppBarLayout>
mein toolbarTop Layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/Base.ThemeOverlay.AppCompat.Dark"
android:id="@+id/topBar"
android:background="@color/colorPrimary">
</android.support.v7.widget.Toolbar>
und mein tablayout Fragment:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_marginBottom="?android:attr/actionBarSize"
android:layout_height="match_parent">
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
app:tabMaxWidth="0dp"
app:tabGravity="fill"
app:tabMode="fixed"
android:elevation="6dp"
android:layout_height="?android:attr/actionBarSize"
android:background="@color/colorPrimary" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
app:layout_scrollFlags="scroll|enterAlways|snap"
android:layout_height="wrap_content" />
</LinearLayout>
Ich habe versucht this answer, aber es war nicht erfolgreich. Ich kann das tablayout nicht im Appbarlayout platzieren (was das Problem löst), da jedes Fragment ein tablayout hat.
Irgendwelche anderen Ideen, um dieses Problem zu lösen?
Setzen Sie diese Eigenschaft in Ihrem 'TabLayout':' android: fillViewport = "false" '. – Ironman
es hat nicht funktioniert ... immer noch das gleiche Ergebnis –