タブを中央揃えにし、表示範囲を一番下まで伸ばす。

イメージ説明### 前提

androidについて質問します。
タブレイアウトを作成しようと思い、Tabbed Activityを選びプロジェクトを作成しました。自分がしたいレイアウトはTwitterのプロフィール画面のように、タブが半分よりも下に繰りようにしたいと思っています。(イメージは画像を参考に)
ですが、調べても出てこないし、android:layout_gravityなどの中央揃えをしても、タブの大きさを変えなければ中央に揃ってくれないので困っています。

実現したいこと

タブを中央揃えにし、表示範囲を一番下まで伸ばす。

該当のソースコード

java

<?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=".MainActivity"> <com.google.android.material.appbar.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/Theme.Tab.AppBarOverlay"> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:minHeight="?actionBarSize" android:padding="@dimen/appbar_padding" android:text="@string/app_name" android:textAppearance="@style/TextAppearance.Widget.AppCompat.Toolbar.Title" /> </com.google.android.material.appbar.AppBarLayout> <androidx.viewpager.widget.ViewPager android:id="@+id/view_pager" android:layout_width="match_parent" android:layout_height="729dp" android:layout_gravity="center" app:layout_anchor="@+id/view_pager" app:layout_anchorGravity="bottom|center" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <com.google.android.material.tabs.TabLayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" /> </androidx.viewpager.widget.ViewPager> <com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_marginEnd="@dimen/fab_margin" android:layout_marginBottom="16dp" app:srcCompat="@android:drawable/ic_dialog_email" /></androidx.coordinatorlayout.widget.CoordinatorLayout>

コメントを投稿

0 コメント