私はviewPager内のviewPagerを使用していました。画像とテキストを各タブに設定したいと思います。 私はこのようなことをしたい - Mock up designtablayoutのタブ内に画像とテキストを含む高さと余白をそれぞれ設定
これまでのところ、タブ&の余白に画像を追加しました。しかし、タブ間のマージンがなぜ機能していないのか分かりません。
<LinearLayout 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:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.ansh.customizingtab.MainActivity">
<android.support.design.widget.TabLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/tabLayout"
app:tabMode="scrollable"
app:tabGravity="fill"
android:layout_margin="10dp"
app:tabPaddingStart="8dp"
app:tabPaddingEnd="8dp"
app:tabBackground="@drawable/background_tab">
</android.support.design.widget.TabLayout>
<com.example.ansh.customizingtab.CustomViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
この結果 - - Result image
** CustomViewPager **のコードを表示します。幅に「wrap_content」を使用して、高さにwrap_contentを強制してみてください。 –
現在、CustomViewPagerには何もありません。私はそれを使ってスワイプ効果を無効にしました。 @GeetChoubey –