Android的 - 片段应用,如何添加脚注? [英] Android - Fragment application, how to add a footer?

查看:132
本文介绍了Android的 - 片段应用,如何添加脚注?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个Android应用程序有4个选项卡。

I'm working on an android application with 4 tabs.

下面是我的activity_main.xml中

Here is my activity_main.xml

 <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="match_parent">

 </android.support.v4.view.ViewPager>

这是我的标签之一(他们都是相同的时刻)

and here is one of my tab (they are all the same for the moment)

 <?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:orientation="vertical"
     android:background="#ff8400" >

     <TextView android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:gravity="center"
         android:text="Top Screen"
         android:textSize="20dp"
         android:layout_centerInParent="true"/>


 </RelativeLayout>

我怎么可以添加一个页脚,这将是每个选项卡上可见?

How could I add a footer that would be visible on each tab?

这是添加在滚动的标签是保持可见的球员。

It's to add a player that stays visible while scrolling the tab.

感谢您

推荐答案

您会需要作出改变,以您的主要活动布局。您可以使用的LinearLayout或RelativeLayout的做到这一点。因为LinearLayout中是比较便宜,我会告诉你,在这里。

You're going to need to make a change to your main activity layout. You can do it with a LinearLayout or RelativeLayout. Because a LinearLayout is less expensive I will show you that here.

<?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:orientation="vertical">

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

    <View
        android:id="@+id/music_player"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
</LinearLayout>

该视图可以得到什么,我会建议使用的FrameLayout那​​里投入片段,如果它会是一个音乐播放器那么复杂。这是如何工作的是你设置musicplayer(WRAP_CONTENT)的高度和你告诉寻呼机占用空间的其余部分layout_height =0dp和layout_weight =1。

The view could been anything, I would recommend using a framelayout there and putting in a fragment if it is going to be as complicated as a music player. How this works is you set the height of the musicplayer (wrap_content) and you tell the pager to take up the rest of the space with layout_height="0dp" and layout_weight="1".

如果你想要做一个RelativeLayout的那么musicplayer会alignParentBottom =true和寻呼机将有layout_above =@ + ID / music_player有两种layout_height =matchparent或alignParentTop =真。

If you want to do a RelativeLayout then the musicplayer would alignParentBottom="true" and the pager would have layout_above="@+id/music_player with either layout_height="matchparent" or alignParentTop="true".

这篇关于Android的 - 片段应用,如何添加脚注?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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