【发布时间】:2015-05-17 02:33:00
【问题描述】:
我在父 XML 中有如下代码行:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/header_parent_layout"
layout="@layout/common_header_layout" />
<include
android:id="@+id/title_header_layout"
layout="@layout/title_header_layout" />
<LinearLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" />
</LinearLayout>
然后我有另一个 xml,我想在 LinearLayout 中添加 id:content 布局在第一个 xml 中由下面的 xml 膨胀:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:customviews="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/agenday_account_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<!-- More Code -->
</FrameLayout>
我已经在膨胀的 xml 布局中设置了 center_vertical 重力,但它总是显示在顶部。任何人都可以帮助如何治疗这个。
下面的代码是我如何添加它的:
View view = getLayoutInflater().inflate(R.layout.second, null);
if (view != null) {
mContentContainer.addView(view);
}
mContentContainer 是父容器。
【问题讨论】:
-
是
mContentView你的 id:content 布局吗?
标签: java android alignment android-linearlayout center