GVKun编程网logo

android – AppBarLayout fitsSystemWindows true attr使CircularIndicator不可见(安卓appbarlayout)

1

对于android–AppBarLayoutfitsSystemWindowstrueattr使CircularIndicator不可见感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍安卓app

对于android – AppBarLayout fitsSystemWindows true attr使CircularIndicator不可见感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍安卓appbarlayout,并为您提供关于2022-09-30:以下go语言代码输出什么?A: true true false true false; B: true false false true false; C: true true、2022-10-28:以下go语言代码输出什么?A:false false;B:true false;C:true true;D:false true。 package main import “f、Android - fitsSystemWindows 属性问题、android 布局xml中 android:fitsSystemWindows="true"的作用的有用信息。

本文目录一览:

android – AppBarLayout fitsSystemWindows true attr使CircularIndicator不可见(安卓appbarlayout)

android – AppBarLayout fitsSystemWindows true attr使CircularIndicator不可见(安卓appbarlayout)

我在下面给出的个人资料页面中使用了Jake Wharton的 CirclePageIndicator.

图像容器是一个viewpager,圆形指示器显示在它的底部.

我需要将appbar的fitsSystemWindows attr设置为true,以便使bugbars可以运行.但是当使用这个attr circlePagerIndicator消失时.

在此先感谢您的帮助;)

<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar_profile"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:titleEnabled="false"
        app:contentScrim="@color/colorPrimary"
        app:statusBarScrim="@color/colorPrimaryDark"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <RelativeLayout
            app:layout_collapseMode="none"
            android:layout_width="match_parent"
            android:layout_height="400dp">

            <android.support.v4.view.ViewPager
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/photo_pager"/>

            <com.indate.indicator.CirclePageIndicator
                android:id="@+id/indicator"
                android:padding="10dip"
                android:layout_height="wrap_content"
                android:layout_width="match_parent"
                android:layout_alignBottom="@+id/photo_pager"
                />

        </RelativeLayout>

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin"
            android:background="@android:color/transparent"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

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

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

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:elevation="6dp"
    app:layout_anchor="@id/app_bar_profile"
    app:layout_anchorGravity="bottom|right|end"
    app:rippleColor="@color/colorAccentRipple"
    android:layout_margin="@dimen/fab_margin"
    android:src="@android:drawable/ic_menu_edit"/>


<android.support.v4.widget.nestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    >
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="@dimen/activity_horizontal_margin">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="18sp"
            android:paddingBottom="8dp"
            android:text="John Doe" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="8dp"
            android:text="1 dk önce" />


        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="8dp"
            android:textColor="?colorAccent"
            android:textSize="12sp"
            android:text="ABOUT ME" />


        <TextView
            android:id="@+id/text_about_me"
            android:paddingTop="8dp"
            android:paddingBottom="8dp"
            android:text="Simply me,nothing more..."
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>


        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:textColor="?colorAccent"
            android:textSize="12sp"
            android:text="OVERVIEW" />

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

            <ImageButton
                android:layout_width="24dp"
                android:layout_height="24dp"
                android:background="@android:color/transparent"
                android:src="@drawable/gender"/>

            <TextView
                android:id="@+id/text_gender_age"
                android:padding="8dp"
                android:text="M,28"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

        </LinearLayout>

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

            <ImageButton
                android:layout_width="24dp"
                android:layout_height="24dp"
                android:background="@android:color/transparent"
                android:src="@drawable/pin"/>

            <TextView
                android:id="@+id/text_place"
                android:padding="8dp"
                android:text="Ankara,Turkey"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

        </LinearLayout>

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

            <ImageButton
                android:layout_width="24dp"
                android:layout_height="24dp"
                android:background="@android:color/transparent"
                android:src="@drawable/logo"/>

            <TextView
                android:id="@+id/text_member_since"
                android:padding="8dp"
                android:text="Member since May 2012"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

        </LinearLayout>

    </LinearLayout>
</android.support.v4.widget.nestedScrollView>

解决方法

AppBarLayout android:fitsSystemWindows =“true”让它在某种程度上与CollapsingToolbarLayout中的RelativeLayout混淆.似乎有一个bug.所以我删除它,它就像一个魅力.

<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar_profile"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:titleEnabled="false"
        app:contentScrim="@color/colorPrimary"
        app:statusBarScrim="@color/colorPrimaryDark"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">


        <android.support.v4.view.ViewPager
            android:layout_width="match_parent"
            android:layout_height="400dp"
            android:id="@+id/photo_pager"/>

        <com.indate.indicator.CirclePageIndicator
            android:id="@+id/indicator"
            android:padding="10dip"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:layout_gravity="bottom"
            />


        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin"
            android:background="@android:color/transparent"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

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

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

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:elevation="6dp"
    app:layout_anchor="@id/app_bar_profile"
    app:layout_anchorGravity="bottom|right|end"
    app:rippleColor="@color/colorAccentRipple"
    android:layout_margin="@dimen/fab_margin"
    android:src="@android:drawable/ic_menu_edit"/>


<android.support.v4.widget.nestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    >
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="@dimen/activity_horizontal_margin">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="18sp"
            android:paddingBottom="8dp"
            android:text="John Doe" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="8dp"
            android:text="1 dk önce" />


        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="8dp"
            android:textColor="?colorAccent"
            android:textSize="12sp"
            android:text="ABOUT ME" />


        <TextView
            android:id="@+id/text_about_me"
            android:paddingTop="8dp"
            android:paddingBottom="8dp"
            android:text="Simply me,Turkey"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

        </LinearLayout>

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

            <ImageButton
                android:layout_width="24dp"
                android:layout_height="24dp"
                android:background="@android:color/transparent"
                android:src="@drawable/logo"/>

            <TextView
                android:id="@+id/text_member_since"
                android:padding="8dp"
                android:text="Member since May 2012"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

        </LinearLayout>

    </LinearLayout>
</android.support.v4.widget.nestedScrollView>

2022-09-30:以下go语言代码输出什么?A: true true false true false; B: true false false true false; C: true true

2022-09-30:以下go语言代码输出什么?A: true true false true false; B: true false false true false; C: true true

2022-09-30:以下go语言代码输出什么?A: true true false true false; B: true false false true false; C: true true true false false;D: true true false true true。

package main

func main() {
    var (
        a int         = 0
        b int64       = 0
        c interface{} = int(0)
        d interface{} = int64(0)
    )

    println(c == 0)
    println(c == a)
    println(c == b)
    println(d == b)
    println(d == 0)
}

答案选A。第3个为false,是因为c是int类型,b是int64类型。第5个为false,那是因为d是int64类型,0是int类型,这个0很容易被当成无类型,会误认为是true。从这里可以看出,做比较的时候,是没有无类型的概念的。

2022-10-28:以下go语言代码输出什么?A:false false;B:true false;C:true true;D:false true。 package main import “f

2022-10-28:以下go语言代码输出什么?A:false false;B:true false;C:true true;D:false true。 package main import “f

2022-10-28:以下go语言代码输出什么?A:false false;B:true false;C:true true;D:false true。

package main

import "fmt"

func main() {
    s := []string{"A", "B", "C"}

    t := s[:1]
    fmt.Println(&s[0] == &t[0])

    u := append(s[:1], s[2:]...)
    fmt.Println(&s[0] == &u[0])
}

答案选C。这里的关键点是 append(s[:1], s[2:]...) 会不会导致扩容。s[:1] 相当于 s[:1:3],即容量是也是 3,因此 append 一个元素(s[2:]...)并不会导致扩容,因此第一个元素还是原来 s[0] 的元素。

Android - fitsSystemWindows 属性问题

Android - fitsSystemWindows 属性问题

如何解决Android - fitsSystemWindows 属性问题

我需要你的帮助来理解一种奇怪的行为。当我将 fitsSystemWindows 属性设置为“true”时,导航栏隐藏了我的布局的某些部分,请参见下图:

当我设置为 false 时,我有这种行为(没关系):

当我阅读 Android 文档和 Stackoverflow 上的许多帖子时,我明白它应该与此行为完全相反:https://developer.android.com/reference/android/view/View#attr_android:fitsSystemWindows。 fitsSystemWindows=''true'' 的第一种情况应该没问题,第二种情况应该被导航栏隐藏,我错了吗?

有人能解释一下发生了什么吗?我的 targetVersionSdk 是 29,我在许多版本(Android 6,7 10 和 11)上对其进行了测试。也许它特定于 CoordinatorLayout ?谢谢你的解释:)

这是我的 xml 布局:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. android:id="@+id/main_content"
  5. android:layout_width="match_parent"
  6. android:layout_height="match_parent"
  7. android:fitsSystemWindows="[true or false]">
  8. <com.google.android.material.appbar.AppBarLayout
  9. android:id="@+id/appbar"
  10. android:layout_width="match_parent"
  11. android:layout_height="wrap_content"
  12. android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
  13. <androidx.appcompat.widget.Toolbar
  14. android:id="@+id/toolbar"
  15. android:layout_width="match_parent"
  16. android:layout_height="wrap_content"
  17. android:background="?attr/colorPrimary"
  18. android:minHeight="?attr/actionBarSize"
  19. app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
  20. </com.google.android.material.appbar.AppBarLayout>
  21. [...]
  22. <com.google.android.material.floatingactionbutton.FloatingActionButton
  23. android:id="@+id/fab"
  24. android:layout_width="wrap_content"
  25. android:layout_height="wrap_content"
  26. android:layout_gravity="end|bottom"
  27. android:layout_marginBottom="@dimen/activity_vertical_margin"
  28. android:layout_marginEnd="@dimen/activity_vertical_margin"
  29. android:src="@drawable/ic_arrow_forward_white_24dp" />
  30. </androidx.coordinatorlayout.widget.CoordinatorLayout>

解决方法

我认为该视图按预期工作。首先,您需要了解插图以及它是如何传递的。 fitsSystemWindow 的默认行为是消耗所有插入并将它们应用为填充。但是像 CoordinatorLayout、DrawerLayout 这样的 ViewGroup 会覆盖这种行为。

这是 CoordinatorLayout 中覆盖行为的代码片段。

  1. private void setupForInsets() {
  2. if (Build.VERSION.SDK_INT < 21) {
  3. return;
  4. }
  5. if (ViewCompat.getFitsSystemWindows(this)) {
  6. if (mApplyWindowInsetsListener == null) {
  7. mApplyWindowInsetsListener =
  8. new androidx.core.view.OnApplyWindowInsetsListener() {
  9. @Override
  10. public WindowInsetsCompat onApplyWindowInsets(View v,WindowInsetsCompat insets) {
  11. return setWindowInsets(insets);
  12. }
  13. };
  14. }
  15. ViewCompat.setOnApplyWindowInsetsListener(this,mApplyWindowInsetsListener);
  16. setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
  17. | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
  18. } else {
  19. ViewCompat.setOnApplyWindowInsetsListener(this,null);
  20. }
  21. }

如您所见,在 CoordinatorLayout 中应用 fitsSystemWindow 会导致它在系统 UI 下呈现内容。您需要做的是添加系统提供的 insets 并将其作为边距或填充应用于顶部和底部视图。

您可以使用 setOnApplyWindowInsetsListener() 来监听插入并应用它。假设您有bottomNav 作为底部视图,那么您可以执行类似的操作来解释底部插入。

  1. ViewCompat.setOnApplyWindowInsetsListener(bottomNav) { view,insets ->
  2. bottomNav.updatePadding(bottom = insets.systemWindowInsetBottom)
  3. insets
  4. }

您可以在 this 博文中了解有关插图的更多信息。

android 布局xml中 android:fitsSystemWindows=

android 布局xml中 android:fitsSystemWindows="true"的作用


android 布局xml中 android:fitsSystemWindows="true"的原文解析为:

Boolean internal attribute to adjust view layout based on system windows such as the status bar. If true, adjusts the padding of this view to leave space for the system windows. Will only take effect if this view is in a non-embedded activity.

内置的一个布尔值属性,通过其去调整基于系统窗口的视图布局,例如状态栏,如果该值为真,调整这个视图的内边距与系统窗口的距离,只有该view是non-embedded(非嵌入的)的activity才会产生影响。

即在开放过程中设计应用程序布局时当考虑当系统窗口的影响时,设置该值,如果为true,将自动调整系统窗口布局来适应你自定义的布局。例如:当系统有状态栏,你的应用也存在状态栏时便可以设置为ture。

关于android – AppBarLayout fitsSystemWindows true attr使CircularIndicator不可见安卓appbarlayout的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于2022-09-30:以下go语言代码输出什么?A: true true false true false; B: true false false true false; C: true true、2022-10-28:以下go语言代码输出什么?A:false false;B:true false;C:true true;D:false true。 package main import “f、Android - fitsSystemWindows 属性问题、android 布局xml中 android:fitsSystemWindows="true"的作用的相关知识,请在本站寻找。

本文标签: