Reputation: 376
I trying to achieve one layout like this:
The problem is that i cant center fragment on viewpager. I already try to change gravitys, and everything but i cant. There is some of mycode:
<android.support.design.widget.CollapsingToolbarLayout
>
<RelativeLayout
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_weight="1"
android:gravity="center" />
</RelativeLayout>
(...)
</android.support.design.widget.CollapsingToolbarLayout>
Fragment child have that code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/infos"
android:weightSum="3"
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
(...)</LinearLayout>
With this code im geting something like this:
Upvotes: 1
Views: 298
Reputation: 1950
Please update your layout like this:
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="190dp"
android:layout_marginTop="25dp"
android:paddingLeft="25dp"
android:paddingRight="25dp"
/>
Feel free to tailor padding/height to fit your UI.
Upvotes: 1