2014-12-03 138 views
0

我试图位置的下方视图寻呼机指示器的问题是,我使用layout_height(harcoded值474dp)可以使用动态宽度高度以便放置下面视图寻呼机指示器ViewPager动态宽度高度

<?xml version="1.0" encoding="utf-8"?> 

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="#dddddd"> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="#dddddd"> 


<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/pager" 
    android:layout_width="match_parent" 
    android:layout_height="274dp" 
    android:layout_below="@+id/title" 
    android:layout_marginBottom="10dp"></android.support.v4.view.ViewPager> 

<CirclePageIndicator android:id="@+id/indicator" 
    android:layout_height="wrap_content" 
    android:layout_width="match_parent" 
    android:layout_below="@+id/pager" 
    app:pageColor="#858585" 
    app:fillColor="#f19201" /> 

</RelativeLayout> 
</ScrollView> 
+0

所以如果高度固定,那么指标不可见? – KOTIOS 2014-12-03 10:57:33

+0

我不想使用固定高度的视图寻呼机,因为它不会在很多设备上工作我想使用wrap_content但与此ViewPager是不可见的 – sger 2014-12-03 11:02:01

+0

好的谢谢,但如果我在线性视图顶部使用TextView打破宽度查看传呼机 – sger 2014-12-03 11:34:59

回答

0

您正在尝试使用RelativeLayout一个滚动视图它永远不会工作,更换或用LinearLayout

0

使用的LinearLayout体重财产包裹这里面:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#dddddd" 
    android:orientation="vertical"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"> 
     <android.support.v4.view.ViewPager 
      android:id="@+id/pager" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"/> 

    </LinearLayout> 

    <com.pockee.views.CirclePageIndicator 
     android:id="@+id/indicator" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="5dp" 
     app:pageColor="#858585" 
     app:fillColor="#f19201" /> 

</LinearLayout> 
+0

高度0dp图像不可见 – sger 2014-12-03 11:20:49

+0

@ sger,现在检查更新的答案。 – 2014-12-03 11:22:10