Android 如何在活动中使片段显示在表格布局下方?
在我的活动中,我有: 在我的片段中,我有: 我在活动代码中动态添加片段。现在看起来是这样的:Android 如何在活动中使片段显示在表格布局下方?,android,android-fragments,android-tablayout,Android,Android Fragments,Android Tablayout,在我的活动中,我有: 在我的片段中,我有: 我在活动代码中动态添加片段。现在看起来是这样的: 我希望我的片段与活动中的表格布局对齐。如何实现这一点?添加到新的框架布局中 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" andr
我希望我的片段与活动中的表格布局对齐。如何实现这一点?添加到新的框架布局中
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/find_friend_fragment_container"
>
<android.support.design.widget.TabLayout
android:id="@+id/find_friends_options_tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.design.widget.TabLayout>
<FrameLayout
android:layout_below="@+id/find_friends_options_tab_layout"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</RelativeLayout>
将我的评论迁移到答案,因为它有助于修复它:
换最外层换最外层谢谢@Vucko!你应该在下面更正你的答案。没问题。行。也谢谢你。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".fragment.SuggestedFriendsFragment">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Suggested friends"
android:textSize="16sp"
android:textStyle="bold"
android:background="#f2f2f2"
android:id="@+id/suggested_friend_text_view"
android:height="50dp"
android:gravity="center_vertical"
android:paddingStart="16dp"
android:paddingLeft="16dp" />
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/suggested_friends_recycler_view"/>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/find_friend_progress_bar"
android:layout_gravity="center"/>
</LinearLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/find_friend_fragment_container"
>
<android.support.design.widget.TabLayout
android:id="@+id/find_friends_options_tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.design.widget.TabLayout>
<FrameLayout
android:layout_below="@+id/find_friends_options_tab_layout"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</RelativeLayout>
transation.replace(R.id.container,fragment);