【发布时间】:2016-01-17 20:49:40
【问题描述】:
您好我有以下问题,当按下选项卡图标时,视图未显示,我可以看到类正在加载。我可以在控制台日志中看到那个。我认为问题与 xml 有关,因为我已将相对布局 main_content 移动到视图寻呼机下方,并且当在选项卡布局中按下图标时,会显示选项卡片段内容,但主要内容视图未附加,那就是一个问题。
我的布局:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimaryDark"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="@dimen/custom_tab_layout_height"
app:tabGravity="fill"
app:tabMode="fixed" />
<RelativeLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
</RelativeLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v4.view.ViewPager>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
<RelativeLayout
android:id="@+id/drawer_pane"
android:layout_width="280dp"
android:layout_height="match_parent"
android:layout_gravity="start">
<!-- Profile box -->
<RelativeLayout
android:id="@+id/profile_box"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@color/material_blue_grey_800"
android:gravity="center_vertical">
<ImageView
android:id="@+id/icon"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="10dp"
android:background="@drawable/ic_mail_black_24dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@+id/icon"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Phong"
android:textColor="#fff"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PTIT HCM"
android:textColor="#fff"
android:textSize="16sp" />
</LinearLayout>
</RelativeLayout>
<!-- Navigation Listview -->
<ListView
android:id="@+id/nav_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/profile_box"
android:background="#ffffff"
android:choiceMode="singleChoice">
</ListView>
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
【问题讨论】:
标签: android android-layout android-viewpager android-tabactivity