gpt4 book ai didi

android - TabLayout 在 Appbar 布局内部使用时不可见

转载 作者:行者123 更新时间:2023-11-29 02:33:44 27 4
gpt4 key购买 nike

这是我的 main_activity.xml 代码

<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/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">

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

<include
android:id="@+id/toolbar"
layout="@layout/toolbar_home"/>

<include
android:id="@+id/appbar"
layout="@layout/appbar_main" />

</LinearLayout>


<FrameLayout
android:layout_width="250dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="@android:color/white"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<com.mindorks.placeholderview.PlaceHolderView
android:id="@+id/drawerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"/>

</FrameLayout>

这是我的 appbar_main.xml Activity 代码

<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
android:id="@+id/MyAppbar"
android:layout_width="match_parent"
android:layout_height="256dp"
android:fitsSystemWindows="true">

<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapse_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true">

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

<ImageView
android:layout_gravity="center"
android:id="@+id/imageView3"
android:layout_width="85dp"
android:layout_height="61dp"
android:src="@drawable/badge"
android:layout_marginTop="10dp" />

<TextView
android:layout_gravity="center"
android:id="@+id/nameTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Krishna Pujar"
android:textColor="@color/hintTextColor" />

<TextView
android:id="@+id/university"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="JNV Dharwad"
android:textColor="@color/hintTextColor" />

</LinearLayout>

<LinearLayout
android:layout_gravity="center"
android:layout_marginTop="60dp"
android:orientation="vertical"
android:layout_width="300dp"
android:layout_height="40dp">

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

<TextView
android:id="@+id/level"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Level - XX"
android:textColor="@color/hintTextColor" />

<TextView
android:id="@+id/points"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="166dp"
android:text="1XX Points"
android:textColor="@color/hintTextColor"/>

</LinearLayout>

<ProgressBar
android:layout_gravity="center"
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="8dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:background="#ffffff"
android:minHeight="60dp"
android:minWidth="220dp" />

</LinearLayout>

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

<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:minHeight="60dp"
tabGravity="fill"
tabIndicatorColor="#000000"
tabMode="fixed"
tabSelectedTextColor="#000000"
android:background="@color/tabs"/>



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

<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/pager_header"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

问题:1.我的工具栏是半可见的2.标签不可见

图片供您引用:

  1. 我的工具栏只显示一半预期:

    实际: broken toolbar Tool bar is properly visible with FLA icon

    1. 标签不可见预期的: Tabs are visible clearly, LEARNING AND QUIZ

    实际: Tabs not visible in this picture

最佳答案

应用程序栏.xml

    <android.support.design.widget.AppBarLayout
android:id="@+id/MyAppbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">

<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/black_shadow_center" />

<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapse_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|exitUntilCollapsed">

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

<ImageView
android:id="@+id/imageView3"
android:layout_width="85dp"
android:layout_height="61dp"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:src="@drawable/fav" />

<TextView
android:id="@+id/nameTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="8dp"
android:text="Krishna Pujar"
android:textColor="@color/colorPrimaryDark" />

<TextView
android:id="@+id/university"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="JNV Dharwad"
android:textColor="@color/colorPrimaryDark" />

</LinearLayout>

<LinearLayout
android:layout_width="300dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginTop="60dp"
android:orientation="vertical">

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

<TextView
android:id="@+id/level"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Level - XX"
android:textColor="@color/colorPrimaryDark" />

<TextView
android:id="@+id/points"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="166dp"
android:text="1XX Points"
android:textColor="@color/black_shadow_center" />

</LinearLayout>

<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="8dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:background="#ffffff"
android:minHeight="60dp"
android:minWidth="220dp" />

</LinearLayout>

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



<android.support.design.widget.TabLayout
android:id="@+id/tabs"
tabGravity="fill"
tabIndicatorColor="#000000"
tabMode="fixed"
tabSelectedTextColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@color/colorPrimary"
android:minHeight="60dp" />


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

<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/pager_header"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>

activity_main.xml

<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/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">

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

<include
android:id="@+id/appbar"
layout="@layout/appbar_main" />

</LinearLayout>


<FrameLayout
android:layout_width="250dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="@android:color/white"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<com.mindorks.placeholderview.PlaceHolderView
android:id="@+id/drawerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />

</FrameLayout>
</android.support.v4.widget.DrawerLayout>

关于android - TabLayout 在 Appbar 布局内部使用时不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48199571/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com