【问题标题】:Unwanted padding in CollapsibleToolbarLayoutCollapsibleToolbarLayout 中不需要的填充
【发布时间】:2016-02-05 14:55:50
【问题描述】:

我的布局中有以下代码:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="global.sti.attendance.SignUpActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="250dp"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsibleToolbarLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:contentScrim="?attr/colorPrimary">

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="centerCrop"
                android:src="@mipmap/colorful_background"
                app:layout_collapseMode="parallax"
                android:adjustViewBounds="true"/>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:layout_collapseMode="pin"/>

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

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

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

滚动效果很好,但是在我的 CollapsingToolbarLayout 中有不需要的填充,结果如下:

似乎是什么问题?谢谢!

PS:我已经将我的布局包装在 coordinatorlayout 中,我不知道为什么当我将它粘贴到这里时,stackoverflow 编辑器无法识别它。

【问题讨论】:

  • 你的意思是在图片的两侧?
  • @DeeV 是图片中的空格。

标签: android android-design-library


【解决方案1】:

尝试在您的工具栏上进行设置

app:contentInsetStart="0dp"

【讨论】:

  • 还是一样,我不知道这是否与图像有关,因为我使用高分辨率图像时图像模糊。
  • 你试过在ImageView上设置android:adjustViewBounds="false"吗?
  • 我刚刚尝试了您的代码,但在 ImageView 中使用了不同的图像,对我来说它工作正常(没有边距)......也许是图像......你试过设置一个不同的图像,看看结果是否不同?
猜你喜欢
  • 2013-09-30
  • 1970-01-01
  • 1970-01-01
  • 2014-04-05
  • 2012-09-17
  • 2011-08-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多