6

그래서 내 프로젝트에서 내 CollapsingToolbarLayout과 관련된 이상한 문제가 있습니다. 내 활동이 시작되면이 내 도구 모음 제목 표시 방법입니다 :확장 된 CollapsingToolbarLayout의 제목이 올바르게 표시되지 않습니다.

the expanded title has dots at the end

레이아웃을 붕괴하면이 같은 후 :

collapsed title with dots at the end

예에서 원래의 제목 텍스트입니다 : "UPC VONALKODOS TERMEK "

확장 상태의 제목이 더 길어야한다고 생각합니다 (충분한 공간이 있습니다). 경과 된 상태.

<style name="ExpandedText" parent="android:TextAppearance"> 
    <item name="android:textColor">@android:color/white</item> 
    <item name="android:textSize">20sp</item> 
    </style> 

지원 라이브러리 버전 :

<?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" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    app:theme="@style/PolarThemeNoActionBar"> 
    <android.support.v4.view.ViewPager 
     android:id="@+id/pager" 
     android:layout_below="@+id/tablayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"/> 
    <android.support.design.widget.AppBarLayout 
     android:id="@+id/app_bar_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 
     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/collapsing_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="142dp" 
      android:fitsSystemWindows="true" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed" 
      app:contentScrim="?attr/colorPrimary" 
      app:expandedTitleMarginStart="48dp" 
      app:expandedTitleMarginBottom="20dp" 
      app:expandedTitleTextAppearance="@style/ExpandedText"> 
      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:background="?attr/colorPrimary" 
       android:minHeight="?attr/actionBarSize" 
       app:layout_collapseMode="pin"/> 
      </android.support.design.widget.CollapsingToolbarLayout> 
     <android.support.design.widget.TabLayout 
      android:id="@+id/tablayout" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:layout_below="@+id/toolbar" 
      android:minHeight="?attr/actionBarSize" 
      android:gravity="bottom" 
      android:background="?attr/colorPrimary" 
      android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
      app:tabIndicatorColor="?attr/colorPrimaryDark"/> 
     </android.support.design.widget.AppBarLayout> 
    </android.support.design.widget.CoordinatorLayout> 

내 입술/스타일/ExpandedText은 다음과 같습니다처럼이 무엇인지 내 활동의 XML 보인다 25.1.1. 전화 : 넥서스 5 안드로이드 버전 : 6.0.1 (주)

내 질문 : 제목이 확장 된 상태에서 마지막 점과 그것에서 더 보여줄 수있는 공간을 작성하지가 왜?

[편집 1] 문제는 여전히 25.3.0

+1

비교적 최근의 라이브러리 버전에서이 동작이 도입 된 것처럼 보입니다. 이상하게 보였으므로 오래된 프로젝트를 가져 왔고 버전 23.4.0에서 예상대로 작동합니다. 즉, 이전에 언급했듯이 제목은 완전히 축소 된 크기와 영역을 기준으로 줄임표로 표시되지 않고 확장 된 상태로 표시됩니다. 어떤 버전이 변경을 가져 왔는지는 모르겠지만 원본의 git 비난을보고, 제목이 아이콘과 겹칠 수있는 가장자리의 경우를 수정하기 위해 작년 중반에 완료된 것 같습니다. 그럴 가능성이 있다면 문제를 제기하고 지금 되돌릴 수 있습니다. –

+1

@Mike M. 의견을 보내 주셔서 감사합니다. 나는 네가 옳다고 생각한다. 이전 버전의 CollapsingToolbarLayout 제목은 괜찮아 보인다. 나는이 주석을 답으로 게시해야한다고 생각한다. – zkminusck

답변

4

CollapsingToolbarLayout는 헬퍼 클래스를 사용합니다. 이 클래스의 최신 버전에서는 확장 된 제목의 사용 가능한 너비를 축소 상태에서 사용할 수있는 너비를 기준으로 크기에 맞게 제한하고 상태의 텍스트 크기 비율로 조정합니다.

관련 소스 코멘트 : the relevant commit에 노트에 설명 된대로

// If the scaled down size is larger than the actual collapsed width, we need to 
// cap the available width so that when the expanded text scales down, it matches 
// the collapsed width 

이 분명히 제목이 다른 Toolbar 물건을 겹치는 것이 어떤 가장자리 케이스를 해결하기 위해 도입되었다. 아이콘

CTL을 통해 표시

수정 CollapsingToolbarLayout 그것을 대부분의 상황에서 작동 제목을 확장 할 수 있습니다. 제목이 일 수있는 경우에는 도구 상자의 내용 즉 아이콘에 그려지는 경우가 있습니다.

이 CL은 스크롤하면서/스케일링이 일어나고 없는 제한이 있다는 것을 의미하는, 접힌 및 확장 텍스트 크기가 크기 유사한 에지 케이스를 고정. 이 경우 펼쳐지면 사용 가능한 너비 인 을 제한해야하며 접을 때 접힌 너비와 일치하도록 '배율'을 지정해야합니다.

일반적으로, 나는 모든 반사와 다른 속임수로 자신의 행동을 수정하는 View 클래스로 찢어 대해 해요,하지만이 경우, 주어진 설정이가 정말 무거운를 취할 것 등이다. 도우미 클래스는 일반적으로 라이브러리 패키지 외부에서 액세스 할 수 없으며 해당 인스턴스는 CollapsingToolbarLayout에 비공개이며 크기 조정 계산은 주로 로컬 변수가있는 개인 보조 메서드에서 수행됩니다.

가능성이 있다면 가장 간단한 해결책은이 수정 이전에 게시 된 라이브러리 버전으로 되돌리는 것입니다. 나는이 변화를 가져온 정확한 버전을 결정하지 못했고, support library revision history은 불행히도 그것을 언급하지 않는 것 같습니다. 그러나 그 커밋은 작년 (2016) 중반에 이루어 졌으므로 버전 24.0.0 또는 그 이후 버전이 될 것입니다. 문제가 23.4.0에 없는지 확인할 수 있습니다.

당신이 이것을 원한다면 분명히 file a bug report 수 있습니다. 그러나 그들은 이것이 버그라고 생각합니다. 나는 특히 변경에 따른 부작용 인 줄임표에 대해 불평하는 것 이외에 이전에 제기 된 이슈에 대해서는 특별히 찾지 못했습니다. this tangentially-related one.

+2

잘 정교합니다. –

0

당신은 ellipsizing을 해제 할 수 있습니다 지원 라이브러리 버전으로 남아있다. 당신의 TextAppearance 스타일이 추가 :

<item name="android:ellipsize">none</item> 

을 당신이 수동으로 내가 코드를이 수도 참조 편집 스타일

<item name="android:width">300dp</item> 
+0

답해 주셔서 감사합니다. 그러나 작동하지 않았습니다. 내 CollapsingToolbar 제목도 같습니다. – zkminusck

0

에 폭을 추가하여 생성되는 텍스트 뷰의 폭을 변경할 수 있습니다 필요가 있다면 이

<android.support.design.widget.CoordinatorLayout 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.v4.view.ViewPager 
    android:id="@+id/pager" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_below="@+id/tablayout" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

<android.support.design.widget.AppBarLayout 
    android:id="@+id/app_bar_layout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/collapsing_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="142dp" 
     android:fitsSystemWindows="true" 
     app:contentScrim="?attr/colorPrimary" 
     app:expandedTitleMarginBottom="20dp" 
     app:expandedTitleMarginStart="48dp" 
     app:expandedTitleTextAppearance="@style/ExpandedText" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      android:minHeight="?attr/actionBarSize" 
      app:contentInsetLeft="0dp" 
      app:contentInsetStart="0dp" 
      app:contentInsetStartWithNavigation="0dp" 
      app:layout_collapseMode="pin" /> 
    </android.support.design.widget.CollapsingToolbarLayout> 

    <android.support.design.widget.TabLayout 
     android:id="@+id/tablayout" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:layout_below="@+id/toolbar" 
     android:background="?attr/colorPrimary" 
     android:gravity="bottom" 
     android:minHeight="?attr/actionBarSize" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
     app:tabIndicatorColor="?attr/colorPrimaryDark" /> 
</android.support.design.widget.AppBarLayout> 

을 좋아하고이 작업 클래스

0 일

}

을하고이 고해상도/스타일/: - CollapsingTextHelper - 그릴과 그 제목을 애니메이션하기

<style name="CollapsedAppBar" parent="@android:style/TextAppearance.Medium"> 
    <item name="android:textSize">16sp</item> 
    <item name="android:textColor">@color/white</item> 
    <item name="android:textStyle">normal</item> 
</style> 
<style name="ExpandedAppBar" parent="@android:style/TextAppearance.Medium"> 
    <item name="android:textSize">20sp</item> 
    <item name="android:textStyle">bold</item> 
</style> 
+0

답장을 보내 주셔서 감사합니다. 그러나 작동하지 않습니다. – zkminusck

관련 문제