잠시 동안 문제가되었던 프로젝트에서 걸린 부분이 있습니다.CoordinatorLayout의 NestedScrollView 아래쪽 위젯을 숨기기
나는 AppBarLayout
및 NestedScrollView
을 갖는 CoordinatorLayout
을가집니다. 나는 CollapsibleToobarLayout
과 함께 일하고 있으며 잘 작동합니다. 문제는 NestedScrollView
이 위아래로 스크롤하지 않는다는 것입니다. toolbar
이 접히면 더 이상 스크롤되지 않으므로 위젯은 숨겨집니다.
나는 android:fillViewPort="true"
과 android:layout_gravity="fill_vertical"
을 시도했지만 아무런 변화가 없습니다. 코드는 다음과 같습니다.
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/MyMaterialTheme"
android:fitsSystemWindows="true"
xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="250dp"
android:id="@+id/appBar"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/collapsingToolbar"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="10dp"
app:expandedTitleMarginEnd="10dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:background="@color/colorPrimary">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
android:background="@drawable/bgPicture"
app:layout_collapseMode="pin"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:titleTextAppearance="@style/Toolbar.TitleText"
android:layout_gravity="top"
app:layout_collapseMode="pin"
android:popupTheme="@style/ThemeOverlay.AppCompat.Light"
>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/custom_trash"
android:clickable="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="end"
android:id="@+id/deleteButton"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:fitsSystemWindows="true"
android:layout_gravity="fill_vertical"
android:background="@color/grey"
android:clipToPadding="false"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:fillViewport="true">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:id="@+id/tableLayout">
<TableRow
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_centerHorizontal="false"
>
<TextView
android:layout_height="wrap_content"
android:layout_width="0dp"
android:id="@+id/goalIdTextView"
android:visibility="gone"
/>
<ProgressBar
android:id="@+id/progress"
android:layout_width="match_parent"
android:indeterminate="false"
android:max="100"
android:progress="60"
android:progressDrawable="@drawable/circular_progress_bar"
android:layout_height="match_parent"
style="?android:attr/progressBarStyleHorizontal"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="100%"
android:textColor="#000000"
android:textSize="20sp"
android:textStyle="bold"/>
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAlignment="gravity"
android:layout_gravity="right"
android:id="@+id/progressText"
/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp">
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp">
<EditText
android:layout_weight="1"
android:id="@+id/goalTitle"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="@android:drawable/editbox_background_normal"
android:paddingTop="14dp"
android:textCursorDrawable="@null"
android:paddingBottom="11dp"
android:hint="Goal Title"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp">
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="1"
android:text="@string/deadline_text"
android:textStyle="bold"
/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp">
<EditText
android:id="@+id/dateEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ems="10"
android:layout_weight="1"
android:focusable="false"
android:inputType="date"
android:background="@android:drawable/editbox_background_normal"
android:paddingTop="14dp"
android:paddingBottom="11dp"
/>
<ImageButton
android:id="@+id/selectDate"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="0"
android:layout_toRightOf="@+id/date"
android:contentDescription="@string/select_date"
android:cropToPadding="true"
android:background="@drawable/calendar_icon"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp">
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="1"
android:text="@string/tasks_label"
android:textStyle="bold"
/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/listView"
android:paddingTop="5dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingBottom="10dp"
android:background="@android:drawable/editbox_background_normal"
android:layout_centerHorizontal="true" />
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="@color/colorPrimary">
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1"
android:textAllCaps="false"
android:id="@+id/updateButton"
android:textColor="#000"
android:onClick="updateGoal"
android:textAppearance="?android:textAppearanceLarge"
android:text="@string/submit"
/>
</TableRow>
</TableLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
ListView가 화면에 표시되지 않거나 아무 것도 스크롤 할 수없는 상태입니다. Whatsapp와 같은 앱에서이 기능이 구현 된 것을 보았습니다. 그룹을 클릭하면 접을 수있는 툴바에 프로필 사진이 표시되고 해당 이미지가 공유 된 이미지, 해당 그룹의 전체 사용자 목록, 페이지 하단의 이탈 버튼이 표시된 활동으로 이동합니다. 이것을 달성하기 위해 몇 가지 접근법을 시도했지만 운이 없었습니다.
저는 선형 레이아웃을 사용한 다음 상대 레이아웃을 사용했습니다. 아래쪽 위젯을 볼 수있는 유일한 방법은 NestedScrollView에서 layout_behavior를 제거하는 경우입니다. 미리보기에서 실제로 화면 밖으로 중첩 스크롤보기의 맨 아래를 볼 수 있습니다. 앱을 실행할 때 접을 수있는 툴바가 축소되면 중첩 된 스크롤 뷰는 스크롤을 중지합니다. 내 말은, 스크롤을 사용하는 대부분의 뷰에는 끝까지 도달 한 사용자 (KitKat의 뷰 끝에 오렌지색과 같이)가 있음을 알리는 방법이 있습니다.이 중첩 스크롤 뷰는 해당 부분에 도달하지 않습니다. 나는 어떤 의미가 있습니까? –
내 코드를 사용해 보셨습니까? –
예 슬프게도, 운이 없다. –