ViewPager在android系统正在全屏? [英] ViewPager in android is taking full screen?

查看:119
本文介绍了ViewPager在android系统正在全屏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的xml文件我有一个线性布局具有ViewPager用于显示图像和包含previous和Next按钮选择images.My XML另一线性布局是这样的:

In my xml file I have a Linear layout that has a ViewPager for showing images and another Linear layout that contains previous and Next buttons for selecting images.My xml looks like this:

 <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <android.support.v4.view.ViewPager
            android:id="@+id/pager"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/goto_first"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="first" >
            </Button>

            <Button
                android:id="@+id/goto_last"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="last" >
            </Button>
        </LinearLayout>

    </LinearLayout>

我的问题是,ViewPager正在全屏幕和previous下一个按钮的LinearLayout没有显示出来,因为没有留下任何空间来得出这样的LinearLayout。

My problem is that the ViewPager is taking full screen and the Linearlayout with previous next buttons is not showing up because there is no space left to draw this LinearLayout.

我使用的片段来填充ViewPager与该进入ViewPager片段视图views.The xml文件是:

I am using Fragments to populate ViewPager with views.The xml file for the fragment view that goes into ViewPager is:


<ImageView
    android:id="@+id/ItemImage"
    android:layout_width="320dp"
    android:layout_height="180dp" />

<TextView
    android:id="@+id/ItemText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="left|bottom"
    android:layout_marginBottom="5dp"
    android:textColor="#ffffffff"
    android:textStyle="bold" />
</FrameLayout>

渲染后,我得到的输出是用这种方式:
结果
    1.图像(覆盖45%的屏幕高度)
   结果2.blank空间(覆盖45%的屏幕高度)
   结果3.Textview(10%屏幕高度的覆盖休息)

The output i am getting after rendering is in this manner:
1.image ( covering 45% screen height)
2.blank space (covering 45% screen height)
3.Textview (covering rest of the 10% screen height)

我想要的输出是:
 结果1.图像(覆盖45%的屏幕高度)
   结果2.Textview(覆盖10%的屏幕高度)
   结果3.LinearLayout的按钮(45%屏幕高度的覆盖休息)

The output i want is :
1.image ( covering 45% screen height)
2.Textview (covering 10% screen height)
3.LinearLayout for Buttons (covering rest of the 45% screen height)

推荐答案

只要给那些viewpager:

Just give those to viewpager:

 android:layout_height="0dp"
 android:layout_weight="1"

这篇关于ViewPager在android系统正在全屏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆