在另一个片段上显示片段

时间:2015-12-18 03:35:19

标签: android android-layout android-fragments

基本上,我想做的是:

Fragments lifecycle

    1.-我在活动的“外面”有两个片段。
      2.-现在可能有两种可能性,片段1或片段必须以向上滑动动画显示。
        3.-当片段1都在屏幕上时,片段1总是在片段2之上。
          4.-任何碎片都可以隐藏,正确放置屏幕底部的显示。

          我对布局设计有点失落。我试过了

          bmerge

          我甚至同时展示了他们两个。甚至为每个片段使用不同的片段转换。使用,wifi.sta.disconnect() --settings.lua SSID = "xxxx" APPWD = "yyyy" cfg = { ip="192.168.0.85", netmask="255.255.255.0", gateway="192.168.0.1" } wifi.sta.setip(cfg) wifi.sta.config(SSID,APPWD) wifi.sta.autoconnect(1) -- wait for WIFI ---- function checkWIFI() print("Waiting for WIFI...") ipAddr = wifi.sta.getip() if ( ( ipAddr ~= nil ) and ( ipAddr ~= "0.0.0.0" ) )then print("IP Address: " ..ipAddr) else -- schedule try again tmr.alarm( 0 , 1000 , 0 , checkWIFI) end end tmr.alarm( 0 , 1000 , 0 , checkWIFI) 不起作用。

          开发此设计的最简单方法是什么?

2 个答案:

答案 0 :(得分:0)

试试这个

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="bottom"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="-100dp"
        android:orientation="vertical">

        <FrameLayout
            android:id="@+id/fragment1"
            android:layout_width="match_parent"
            android:layout_height="50dp"
           android:background="@color/colorAccent"
            />

        <FrameLayout
            android:id="@+id/fragment2"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:background="@color/colorPrimary"
            />

    </LinearLayout>

</RelativeLayout>

为linearLayout设置动画。并根据您的要求更改framelayout(消失/可见)的可见性

答案 1 :(得分:0)

对FragmentA使用两个FrameLayouts可能会对这两种情况有所帮助。

  1. 如果它是唯一可见的,您可以使用 机器人:layout_alignParentBottom = “真”

  2. 当它位于FrameLayout顶部时,可以使用FragmentB 机器人:layout_above = “@ + ID / fragment2”

  3. 然后根据您的场景玩这些“可见性”。