2015-10-13 62 views
0

我有一個ViewPager(標準的一個),它被放在ScrollView(萬一頁面將會變大然後屏幕顯示,每個頁面上我都有一個Spinner(進度條)用於顯示數據加載,Spinner以頁面爲中心如何在ViewPager頁面大於屏幕的同時在屏幕上居中顯示?

但是當頁面更大然後篩選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> 

回答

0

您可以添加微調到您的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> 

希望得到這個幫助

+0

它不能解決我的問題,因爲我必須訪問查看尋呼機上的進度條表單頁面。 – LunaVulpo

+1

@LunaVulpo你不能提供回調嗎? – Shark

+0

@Shark也許我可以,但最後我通過編程方式測量屏幕尺寸並將progressBar設置在正確的位置來解決我的問題。 – LunaVulpo