2016-06-16 5 views
0

CollapsingToolbar이라는 간단한 활동이 있습니다. 내가 가지고있는 것을 보여주고 그 문제가 무엇인지 설명해 드리겠습니다. 이 (오른쪽) 당신이 볼 수 있듯이 도구 모음이 확장 될 때CollapsingToolbar를 사용할 때 내 버튼이 숨겨져 있습니다.

collapsed Toolbarexpanded Toolbar

에서, Search button가 표시되지 않습니다 확장 될 때 도구 모음 (왼쪽) 대 축소

. 이 문제를 어떻게 해결할 수 있습니까?

activity_search.xml :

<android.support.design.widget.CoordinatorLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true"> 

    <android.support.design.widget.AppBarLayout 
     android:fitsSystemWindows="true" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/app_bar_height" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:fitsSystemWindows="true" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       app:layout_collapseMode="parallax"/> 

      <android.support.v7.widget.Toolbar 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       app:layout_collapseMode="pin" 
       app:popupTheme="@style/AppTheme.PopupOverlay"/> 

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

    <include 
     layout="@layout/content_search" /> 
</android.support.design.widget.CoordinatorLayout> 

content_search.xml는

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/ll" 
     android:layout_alignParentTop="true" 
     android:layout_marginBottom="@dimen/view_margin" 
     android:orientation="horizontal"> 

     <AutoCompleteTextView 
      android:id="@+id/etIngredients" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1"/> 

     <ImageButton 
      android:id="@+id/btAdd" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/ic_add"/> 
    </LinearLayout> 

    <Button 
     android:id="@+id/btSearch" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:text="@string/search"/> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/rvIngredients" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/btSearch" 
     android:layout_below="@id/ll"/> 
</RelativeLayout> 

이 질문을 검색했는데, 전혀 아무것도 찾을 could'nt있다!

답변

1

접을 수있는 툴바로 인해 숨겨져 있습니다. match_parent라고하면 확장 된 툴바의 높이를 제외한 높이가 사용됩니다. 툴바 높이의 bottom_margin을 추가하기 만하면됩니다.

호프가 도움이 될 것입니다.

+0

의미가 있습니다! 나는 내 PC로 돌아갈 때 이것을 시도 할 것이다. 감사합니다 –

+0

감사. 이 작업을! :) –

+0

당신을 환영합니다 :) – Neo

2

한번에 수정하여 content_search.xml 따라서 :

<LinearLayout 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:orientation="vertical" 
app:layout_behavior="@string/appbar_scrolling_view_behavior" > 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_marginBottom="@dimen/view_margin" 
    android:orientation="horizontal"> 

    <AutoCompleteTextView 
     android:id="@+id/etIngredients" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1"/> 

    <ImageButton 
     android:id="@+id/btAdd" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/ic_add"/> 
</LinearLayout> 

<android.support.v7.widget.RecyclerView 
    android:id="@+id/rvIngredients" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

<Button 
    android:id="@+id/btSearch" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:text="@string/search"/> 
</LinearLayout> 

그리고 당신은, 오른쪽 화면 하단의 검색 버튼을 가지고있는 RecyclerView 위를 이동할 필요가없는 경우.

+0

리사이클러 뷰를 가득 채우면 검색 버튼이 화면 아래로 다시 이동합니다. 픽스를 찾지 못한다면, 당신이 제안한 것처럼 검색 버튼을 맨 위에 놓을 것입니다. –

+1

'EditText'에 입력 된 텍스트를 찾기 위해 버튼을 원한다면 검색 버튼을 바로 'EditText' 아래에 두는 것이 좋습니다. '. 그러나 버튼을 아래쪽에 두어야한다면 레이아웃을 더 복잡하게 만들고'FrameLayout'을 사용할 수 있습니다. 내가 그걸 보여 주길 원한다면 알려줘. –

+0

FrameLayout을 사용한 적이 없지만 Neo의 제안이 효과가있었습니다. 그래도 도와 ​​줘서 고마워. –

1

당신의 content_search.xml

ID android:layout_below="@id/ll"은 무엇인가 확인하시기 바랍니다 ??

저는 이것이 선형 레이아웃의 ID라고 생각합니다.이 부분을 추가하고 도움을 얻으시기 바랍니다.

+0

내 질문에 편집 됨. 첫 번째 LinearLayout입니다. –