Android 要嵌入到活动中的Tabhost FragmentActivity

Android 要嵌入到活动中的Tabhost FragmentActivity,android,android-layout,android-widget,Android,Android Layout,Android Widget,我有一个带有简单按钮的活动(我不能将其作为片段,因为它已经扩展了父活动)和一个作为选项卡主机的片段活动。他们两人是否可以共享视图布局的屏幕空间: 活动布局如下所示: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/controls" android:layout_width="match_parent" android:layout_heigh

我有一个带有简单按钮的活动(我不能将其作为片段,因为它已经扩展了父活动)和一个作为选项卡主机的片段活动。他们两人是否可以共享视图布局的屏幕空间: 活动布局如下所示:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/controls"
    android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
    android:id="@+id/select"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="0dp"
    android:textAppearance="?android:attr/textAppearanceSmall"/>

  <LinearLayout
              android:id="@+id/control_buttons"
        android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:orientation="horizontal"
  android:gravity="center">
<ImageButton
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="0dp"/>
<ImageButton
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="0dp"/>
   <ImageButton
    android:id="@+id/button3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="0dp"/>
 <ImageButton
    android:id="@+id/button4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="0dp"/>


 </LinearLayout>

 <LinearLayout
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:orientation="horizontal"
  android:gravity="center">

  <TextView
    android:id="@+id/addto"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="0dp"
    android:textAppearance="?android:attr/textAppearanceSmall"/>
   <CheckBox
    android:id="@+id/addtoCheck"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="0dp"/>
  </LinearLayout>

 </LinearLayout>
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TabWidget
        android:id="@android:id/tabs"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:background="@color/coffee"/>

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_weight="0"/>

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>

</LinearLayout>

FragmentActivity是一个选项卡主机,它有4个选项卡,布局如下所示:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/controls"
    android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
    android:id="@+id/select"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="0dp"
    android:textAppearance="?android:attr/textAppearanceSmall"/>

  <LinearLayout
              android:id="@+id/control_buttons"
        android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:orientation="horizontal"
  android:gravity="center">
<ImageButton
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="0dp"/>
<ImageButton
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="0dp"/>
   <ImageButton
    android:id="@+id/button3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="0dp"/>
 <ImageButton
    android:id="@+id/button4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="0dp"/>


 </LinearLayout>

 <LinearLayout
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:orientation="horizontal"
  android:gravity="center">

  <TextView
    android:id="@+id/addto"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="0dp"
    android:textAppearance="?android:attr/textAppearanceSmall"/>
   <CheckBox
    android:id="@+id/addtoCheck"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="0dp"/>
  </LinearLayout>

 </LinearLayout>
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TabWidget
        android:id="@android:id/tabs"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:background="@color/coffee"/>

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_weight="0"/>

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>

</LinearLayout>


高度末尾的活动是否可以显示父布局剩余高度的碎片活动?

该活动是屏幕上所有内容的逻辑容器。我想你是在问,活动1是否可以使用部分屏幕,活动2是否可以使用另一部分屏幕


不,这是不可能的。

活动1是一个android.app.activity类,而第二个是一个片段活动,这有帮助吗?PagerView需要碎片活动,而我的活动1不是碎片活动