>  Q&A  >  본문

android - CollapsingToolbarLayout显示标题不全,被截断了

我正在使用CollapsingToolbarLayout显示一个界面,但是当CollapsingToolbarLayout展开的时候,标题没有完全显示,如下图:

我本想显示“this is a long long title.”,结果右边空出了一大段而标题却被截断了。

我按照搜索到的各种方法尝试过了,比如设置margin或者padding,都没有什么用。

所以我应该怎么设置才能让标题完全显示??

下面是我的布局文件

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    android:id="@+id/main_layout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="240dp"
        android:fitsSystemWindows="true">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsingToolbarLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="@color/colorPrimary"
            app:expandedTitleTextAppearance="@style/ExpandedAppBar"
            app:collapsedTitleTextAppearance="@style/CollapsedAppBar"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:id="@+id/toolbarImageView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                android:scaleType="centerCrop"
                app:layout_collapseMode="parallax"
                app:layout_collapseParallaxMultiplier="0.7"/>

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

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

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

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/scrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <WebView
            android:id="@+id/webview"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        </WebView>
    </android.support.v4.widget.NestedScrollView>

</android.support.design.widget.CoordinatorLayout>
PHP中文网PHP中文网2741일 전642

모든 응답(2)나는 대답할 것이다

  • 天蓬老师

    天蓬老师2017-04-18 09:18:21

    이건 처음부터 그렇게 길지는 않습니다. 오른쪽에 공간이 이렇게 많이 있는 이유는 중력 속성을 설정할 수 있기 때문입니다.
    정말 긴 제목을 사용해야 한다면 이 프로젝트를 살펴보세요: multiline-collapsingtoolbar

    회신하다
    0
  • PHPz

    PHPz2017-04-18 09:18:21

    텍스트 모양을 조정해 보시겠어요?

    회신하다
    0
  • 취소회신하다