【发布时间】:2016-01-10 23:22:20
【问题描述】:
我有一个ViewPager(标准),它放在ScrollView中(以防页面比屏幕大。在每个页面上我都有一个Spinner(进度条)用于显示数据加载。 Spinner 以页面为中心。
但是当页面比屏幕大时,Spinner 不会在屏幕上居中,因为它在页面上居中,Spinner 在屏幕底部(甚至隐藏在屏幕下方)。
那么如何设置Spinner 居中在屏幕上(而不是在页面上)?
更新: 微调器必须在 viewpager 中的页面上,因为每个页面都必须加载一些数据表单服务器,并且微调器指示每个页面的加载过程分开。
这是寻呼机的位置:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white" />
</LinearLayout>
这是一个页面布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true">
<GridView
android:id="@+id/my_gird"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="72dp"/>
<TextView
android:id="@+id/test_text"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="!!!!!!" />
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
/>
</RelativeLayout>
【问题讨论】:
标签: android android-layout android-viewpager centering