【发布时间】:2016-05-19 22:44:13
【问题描述】:
我的 XML 设计遇到了一些问题。我在我的应用程序中添加了一个 Viewpager,并在应用程序顶部添加了一个工具栏。所以,我的问题是,当我尝试将属于我的 Viewpager 的片段中的项目重心放在中心时,它将被设置在 Viewpager 的中间,而忽略了工具栏的高度。
所以,我想问一下,当父视图没有填满整个屏幕时,是否可以将屏幕中间的视图或片段中的项目居中。
我的活动 XML 是这个:
<RelativeLayout 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"
android:orientation="vertical">
<include layout="@layout/toolbar"
android:id="@+id/toolbar"></include>
<com.example.android.ui.SlidingTabLayout
android:id="@+id/module_selector_tabs"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@color/view_pager_top"
android:layout_below="@id/toolbar"
android:elevation="4dp"/>
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/viewPager"
android:layout_below="@id/module_selector_tabs"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>
我想要居中的项目位于我使用 FragmentAdapter 动态添加到 Viewpager 的 Fragments 中。
现在我的应用看起来像,我只想将计时器文本和 CircleProgressBar 放在整个屏幕的中心,现在它们在 viewpager 的中间对齐:
【问题讨论】:
-
你可以发布你想要的截图吗?
-
添加了照片和更多的定义
标签: android xml android-layout android-fragments android-viewpager