如何在ViewPager圆形指示器中调整图像和文本

时间:2014-03-02 17:56:56

标签: android android-layout android-viewpager viewpagerindicator

我正在尝试将ViewView和TextView放在ViewPager圈指示器中。我想在Imageview下面显示文字,但是文字是由页脚隐藏,它有圆圈指示符。请建议如何在布局中调整其中的三个。布局是:

ViewPager:

 <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_marginBottom="1dp"
            android:layout_marginTop="1dp"
            android:layout_weight="0.8"
            android:background="@color/white"
            android:orientation="vertical" >

            <!-- ViewPager -->

            <android.support.v4.view.ViewPager
                android:id="@+id/viewPager"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" />
           <!-- Footer -->
        <include layout="@layout/footer"  />
        </FrameLayout>

有圆圈指示符的页脚:

<?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:layout_gravity="bottom"
android:orientation="vertical" >

<Button android:layout_height="wrap_content" android:layout_width="wrap_content"
android:id="@+id/btn1" 
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@drawable/rounded_celll" />

 <Button android:layout_height="wrap_content" android:layout_width="wrap_content"
android:id="@+id/btn2"
android:layout_toRightOf="@id/btn1"
android:layout_marginLeft="5dip"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@drawable/rounded_celll" />
 </RelativeLayout>

这是将在ViewPager中显示的layout1:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white"
android:orientation="vertical"
android:layout_gravity="top|center">

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/sp1" 
    android:layout_weight="0.7"/>

<TextView
    android:id="@+id/textView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textSize="10sp"
    android:layout_weight="0.3"
    android:textColor="@color/black"
    android:textStyle="bold"
    android:text="First Layout First Layout First Layout First Layout "
   /> 

1 个答案:

答案 0 :(得分:0)

Lets say as of now you have three layouts -
1) Main layout (which has view pager)
2) footer layout
3) layout having imageView and textView

To achieve your goal, you can do below steps -
 remove "<include layout="@layout/footer" from mail layout and add it as a part of 3) layout.
 This footer view will also be part of viewPager.