Android:片段+始终位于屏幕底部的顶部布局

时间:2012-10-22 05:41:31

标签: android android-fragments android-support-library

我想在我的Android中执行与在他们的iPhone App中相同的pagination and menu(请查看图像)。屏幕底部有一个pagination和应用菜单,它们是always on top。如果某个屏幕有更多内容并滚动,则pagination和菜单位置在底部为fixed,无论用户是向下滚动还是向上滚动。

在回答时,请考虑以下我的Android应用设计规格:

  1. 此应用正在Android 2.1(API级别7)
  2. 中开发
  3. 这是基于片段的应用。我只有一个活动和很多片段(实际上,我为pagination下的每个页面创建了片段,我在滑动时显示和隐藏片段)
  4. iPhone Screenshot

3 个答案:

答案 0 :(得分:0)

要在3.x下的android中使用fragment,您必须使用support library

要在屏幕的特定位置保留一些布局,只需使用Android上的基本布局控件,例如Linearlayout, RelativeLayout,...

答案 1 :(得分:0)

请参阅this project了解您的寻呼要求。

And for bottom layout you can fix the bottom layout inside main layout.

注意: 首先参考项目,然后尝试底层方法。

答案 2 :(得分:0)

这可以很容易地实现。为此活动定义您的内容布局。

<?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" >
     <FrameLayout
            android:id="@+id/simple_fragment"
            android:layout_width="match_parent"
            android:layout_height="0px"
            android:layout_weight="1">
    </FrameLayout>

    <TextView
        android:id="@+id/all_common_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        android:text="Some common layout" />

</LinearLayout

&GT;

并将framelayout替换为片段,以便Textview(all_common_view)对您使用的所有片段保持通用。