Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/225.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 当ViewPager的页面比屏幕大时,如何将视图居中显示在屏幕上?_Android_Android Layout_Android Viewpager_Centering - Fatal编程技术网

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也许我可以,但最后我通过编程测量屏幕大小并将进度条设置在正确的位置来解决我的问题。