Android 当ViewPager的页面比屏幕大时,如何将视图居中显示在屏幕上?
我有一个Android 当ViewPager的页面比屏幕大时,如何将视图居中显示在屏幕上?,android,android-layout,android-viewpager,centering,Android,Android Layout,Android Viewpager,Centering,我有一个ViewPager(标准的一个),它放在ScrollView(以防页面比屏幕大。在每个页面上我都有一个微调器(进度条),用于显示数据加载。微调器位于页面中央 但是当页面大于屏幕时,微调器不在屏幕中央,因为它位于页面中央,而微调器位于屏幕底部(甚至隐藏在屏幕下方) 那么如何将微调器设置在屏幕中心(而不是页面中心) 更新:微调器必须位于viewpager中的页面上,因为每个页面都必须加载一些数据表单服务器,微调器分别指示每个页面的加载过程 以下是寻呼机的位置: <?xml versio
ViewPager
(标准的一个),它放在ScrollView
(以防页面比屏幕大。在每个页面上我都有一个微调器(进度条),用于显示数据加载。微调器位于页面中央
但是当页面大于屏幕时,微调器不在屏幕中央,因为它位于页面中央,而微调器位于屏幕底部(甚至隐藏在屏幕下方)
那么如何将微调器设置在屏幕中心(而不是页面中心)
更新:微调器必须位于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>
您可以将微调器添加到ViewPager活动中
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ScrollView
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>
</ScrollView>
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
/>
</RealativeLayout>
希望此帮助不会解决我的问题,因为我必须访问view pager中的进度条表单页。@LunaVulpo您不能为此提供回调吗?@Shark也许我可以,但最后我通过编程测量屏幕大小并将进度条设置在正确的位置来解决我的问题。