반응형
AppBarLayout와 CollapsingToolbarLayout을 이용해 상단에 이미지, 텍스트를 넣고 하단에 리사이클러뷰를 넣어놨다
스크롤을 내리면 상단 이미지가 사라지고 상단 텍스트가 툴바 Text 로 올라가는 기능을 구현하고 있었는데......
툴바에 text가 도저히 표시되지 않아서 대체 뭐가 문젤까.............................. 하염없이 모니터를 바라보다 원인을 찾았다ㅠ
해당 xml파일을 보면
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/colToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_collapseMode="parallax"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleTextAppearance="@android:color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:src="@drawable/splash_icon"/>
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:titleTextColor="#FFFFFF"
app:title="hello world"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
대략 코드는 이런식으로 되어있는데 저기 androidx.appcompat.widget.Toolbar에서 layout_height을
wrap_content로 해놨다.........ㅠㅠ 높이를 지정 안해줘서...
여튼 해당 layout_height를
android:layout_height="?attr/actionBarSize"
로 변경하면 원하던 텍스트가 나온다.. 30분은 날린거같아.... 황당하고.. 어이가없어.. 급히 글을 썼다
다음에 Collapsing Toolbar Layout도 제대로 정리 해야할 것 같다 정리할게 너무많네..
'소프트웨어 > 안드로이드[Java]' 카테고리의 다른 글
[Android] Java 타임스탬프 시간 변환 (0) | 2021.06.11 |
---|---|
[Android] Retrofit 에러 - Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $ (0) | 2021.06.05 |
[Android] android.database.CursorIndexOutOfBoundsException (0) | 2021.04.06 |
[Android] BottomNavigationView Fragment 적용 (2) | 2021.04.02 |
[Android] BottomNavigationView 구현하기 (0) | 2021.04.01 |