Android FrameLayout已在运行时扩展,但其子项未使用新值更新

Android FrameLayout已在运行时扩展,但其子项未使用新值更新,android,footer,fragment,android-framelayout,Android,Footer,Fragment,Android Framelayout,在我的应用程序中,我使用以下FrameLayout作为将成为页脚的片段的容器: <FrameLayout android:id="@+id/frameLayoutFooter" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true"/> 我的页脚片段的布局是: <?xml version="1.0" enco

在我的应用程序中,我使用以下FrameLayout作为将成为页脚的片段的容器:

<FrameLayout
android:id="@+id/frameLayoutFooter"
android:layout_width="fill_parent"
android:layout_height="wrap_content" 
android:layout_alignParentBottom="true"/>
我的页脚片段的布局是:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/footerContainer"
android:layout_width="fill_parent"
android:layout_height="165dip"
android:layout_alignParentBottom="true"
android:background="#15355b" >

<RelativeLayout
    android:id="@+id/relativeLayoutTopSetcion"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

..... some buttons and imageviews here...
</RelativeLayout>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativeLayoutBottomSetcion"
    android:layout_width="fill_parent"
    android:layout_height="350dip"
    android:layout_alignParentBottom="true"
    android:visibility="**invisible**" >
..... some more imageviews and textviews here...
</RelativeLayout>
</RelativeLayout>
我做错了什么

消耗品页脚是否有已知的UI模式


提前感谢

我注意到您的代码中有一些问题:

  • 片段中的父级RelativeLayout(带有
    @+id/footerContainer
    )具有固定的
    android:layout高度
    ,为
    165dip
    ,改为
    match\u parent

  • 您还可以删除其上的
    android:layout\u alignParentBottom=“true”
    (由于其父级是FrameLayout-
    layout\u alignParentBottom
    仅适用于RelativeLayout的子级,因此它无论如何都不起作用)

  • 由于我们将第1点上的
    165dip
    更改为
    match\u parent
    ,您应该将框架布局上的
    android:layout\u height=“wrap\u content”
    更改为
    165dip
    ,以获得您想要的内容


  • 有些事情我不明白,这可以回答你的问题:

    首先,为什么在另一个只有165dip的相对布局中有一个350 DIP的RelativeLayout(relativeLayoutBottomSetcion)

    我认为您应该尝试将FrameLayout高度设置为165dip,并将RelativeLayout(footerContainer)高度设置为填充父对象。这将允许“footerContainer”具有与FrameLayout相同的高度,即使将其高度更改为500dip。(此时您将使relativeLayoutBottomSetcion可见,就像您已经在做的那样)

    此外,您应该将可见性设置为“不可见”,而不是“不可见”,因为“不可见”会使您相对占用屏幕上的空间,但不会绘制其内容


    要完成此操作,请删除android:layout\u alignParentBottom=“true”,因为您不需要它,因为RelativeLayout父对象是FrameLayout,并且此属性仅在父对象是RelativeLayout时有效。

    最后,我使用了可见性设置为gone的RelativeLayout,
    并使用从中获取的调整大小动画将其展开。干杯

    您是否尝试过
    frameLayout.invalidate()?是的,没有工作。。。我还尝试将RelativeLayout的内容放入一个新的片段(而不是将其设置为可见),并在运行时(单击按钮)将其添加到页脚中,但这也给了我完全相同的结果。。。,关于如何实现可展开页脚的任何想法??您可以尝试使用alignParentBottom属性在片段布局viewstub中插入并膨胀viewstub。它应该为任何英语拼写错误而工作,希望您理解:)
    
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/footerContainer"
    android:layout_width="fill_parent"
    android:layout_height="165dip"
    android:layout_alignParentBottom="true"
    android:background="#15355b" >
    
    <RelativeLayout
        android:id="@+id/relativeLayoutTopSetcion"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
    
    ..... some buttons and imageviews here...
    </RelativeLayout>
    
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/relativeLayoutBottomSetcion"
        android:layout_width="fill_parent"
        android:layout_height="350dip"
        android:layout_alignParentBottom="true"
        android:visibility="**invisible**" >
    ..... some more imageviews and textviews here...
    </RelativeLayout>
    </RelativeLayout>
    
    ViewGroup.LayoutParams params = mFrameLayoutFooter.getLayoutParams();
    params.height = 500; 
    mFrameLayoutFooter.requestLayout();
    // setting the bootom relative layout to be visible
    mRelativeLayoutBottomSetcion.setVisibility(View.VISIBLE);