1

두 경우 모두 도구 모음 제목이 축소되어 표시되지 않습니다. 다음은 (당신이 설정되지 않은 경우에도 그래도, 예) 내 레이아웃도구 모음 제목이 표시되지 않습니다.

CollapsingToolBarLayout의 제목은 ToolBar에 우선 순위가
<?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:id="@+id/coordinatorLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true"> 

     <android.support.design.widget.AppBarLayout 
      android:id="@+id/appBarLayout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
      android:background="@android:color/transparent" 
      android:fitsSystemWindows="true"> 

      <android.support.design.widget.CollapsingToolbarLayout 
       android:id="@+id/collapsing_toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="@dimen/collapsing_toolbar_height" 
       app:layout_scrollFlags="scroll|exitUntilCollapsed" 
       app:contentScrim="?attr/colorPrimary" 
       app:expandedTitleTextAppearance="@android:color/transparent" 
       android:fitsSystemWindows="true"> 

       <ImageView 
        android:id="@+id/header_image" 
        android:layout_width="match_parent" 
        android:layout_height="@dimen/collapsing_toolbar_height" 
        android:scaleType="centerCrop" 
        android:fitsSystemWindows="true" 
        android:contentDescription="@string/app_name" 
        android:src="@mipmap/ic_launcher" 
        app:layout_collapseMode="parallax"/> 

       <android.support.v7.widget.Toolbar 
        android:id="@+id/toolbar" 
        android:layout_width="match_parent" 
        android:layout_height="?attr/actionBarSize" 
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
        android:title="@string/app_name" 
        app:layout_collapseMode="pin" /> 

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

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



    <android.support.v4.widget.NestedScrollView 
     android:id="@+id/scroll" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:clipToPadding="false" 
     android:layout_marginBottom="100dp" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <RelativeLayout 
      android:id="@+id/rlMain" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <FrameLayout 
       android:id="@+id/container" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"></FrameLayout> 


     </RelativeLayout> 



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

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
     <android.support.design.widget.BottomNavigationView 
      android:id="@+id/bottom_navigation" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      app:itemBackground="@color/faint_black" 
      app:itemIconTint="@color/white" 
      app:itemTextColor="@color/menu_item_color_change" 
      app:menu="@menu/menu" /> 
    </RelativeLayout> 




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

답변

2

입니다. 를 비활성화 할 CollapsingToolBarLayout

app:titleEnabled="false" 

을 추가하고 ToolBar에 하나 표시한다. 당신이 지원 라이브러리

0
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
toolbar.setTitle("Title Name goes here") 
0

에서 도구 모음을 사용하고 있기 때문에 또한 그것은

app:title 

하지 android:title해야 시도 코드에서이 :

<android.support.v7.widget.Toolbar 
        android:id="@+id/toolbar" 
        android:layout_width="match_parent" 
        android:layout_height="?attr/actionBarSize" 
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
        android:title="@string/app_name" 
        app:layout_collapseMode="pin" > 
<TextView 
     android:id="@+id/text_id" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="your_title" 

     android:textSize="20sp"/> 
</android.support.v7.widget.Toolbar> 
+0

당신이 도구 모음의 왼쪽, 오른쪽 또는 중앙에 텍스트를 정렬하는 중력을 추가 할 수 있습니다를 설정하려고 당신의 atvity에 NoActionBar 테마를 설정하고 그런 된 setContentView

후 onCrate 방법 코드 아래

toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);

을 실행 –

0

코드 아래에보십시오 :

CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); 
     collapsingToolbarLayout.setTitle(getString(R.string.app_name)); 
     collapsingToolbarLayout.setExpandedTitleColor(ContextCompat.getColor(this, android.R.color.transparent)); 
0

제목 여기