Android动态更改include标记的布局attr

时间:2016-04-12 21:37:32

标签: android layout dynamic include

我使用<include>标记来包含我的MainActivity中由AppBarLayoutFloatingActionButton合并的布局。

MainActivity在NestedScrollView中有5个片段,底栏可以切换它们。

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myCoordinator"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<include
    android:id="@+id/layout_appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    layout="@layout/appbar_profile" />

<android.support.v4.widget.NestedScrollView
    android:id="@+id/myScrollingContent"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
</android.support.v4.widget.NestedScrollView>

</android.support.design.widget.CoordinatorLayout>

我希望<include>标记layout属性可以重置为其他布局资源(例如setLayoutResource(R.layout.appbar_profile)),同时切换到其他片段(profile页)。

如何动态更改<include>代码的layout属性? THX。

0 个答案:

没有答案
相关问题