3

裏面我是我的搜索最近的問題是:Scrollview inside constraint layout does not scroll to the bottom of the parent constraintAndroid的約束佈局內滾動型約束佈局

但有無解 = |。

我想要做的事:

我有3「零件」的約束佈局:頂吧中間內容底部按鈕

我想僅爲中間內容放置滾動視圖。所以,如果你滾動向下和向上你連續看頂欄底部按鈕

但是這種滾動視圖不工作,我覺得是值得在滾動視圖「match_parent」有關,但我可以't把這個選項,因爲滾動視圖是在約束佈局大小應該是相對的,如果我把匹配父母它不填充所有空格。

我已經使用: fillViewport = 「真」, layout_constraintBottom_toBottomOf = 「父」

按照碼,滾動視圖名稱: 「scrollview2」

<?xml version="1.0" encoding="utf-8"?> 

<!--Create by Canato 26/09/2017--> 

<com.flipboard.bottomsheet.BottomSheetLayout 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/needs_search_bottomsheet" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.constraint.ConstraintLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:layout_editor_absoluteY="25dp" 
    tools:layout_editor_absoluteX="0dp"> 

    <android.support.constraint.Guideline 
     android:id="@+id/horGuideline10" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     app:layout_constraintGuide_percent="0.1" 
     tools:layout_editor_absoluteX="0dp" 
     tools:layout_editor_absoluteY="82dp" /> 

    <android.support.constraint.Guideline 
     android:id="@+id/horGuideline90" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     app:layout_constraintGuide_percent="0.9" 
     tools:layout_editor_absoluteY="536dp" 
     tools:layout_editor_absoluteX="0dp" /> 

    <include 
     android:id="@+id/actionbar" 
     layout="@layout/view_actionbar" 
     android:layout_width="0dp" 
     android:layout_height="0dp" 
     app:layout_constraintBottom_toTopOf="@+id/horGuideline10" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toTopOf="parent" 
     tools:layout_constraintBottom_creator="1" 
     tools:layout_constraintLeft_creator="1" 
     tools:layout_constraintRight_creator="1" 
     tools:layout_constraintTop_creator="1" /> 

    <Button 
     android:id="@+id/needs_search_save_btn" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_marginEnd="8dp" 
     android:layout_marginLeft="8dp" 
     android:layout_marginRight="8dp" 
     android:layout_marginStart="8dp" 
     android:layout_marginTop="8dp" 
     android:background="@drawable/btn_green_bright_half_round_selector" 
     android:gravity="center" 
     android:text="@string/str_continue_save" 
     android:textAllCaps="false" 
     android:textColor="@color/WHITE" 
     android:textSize="@dimen/size_text_button" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintHorizontal_bias="0.0" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toTopOf="@+id/horGuideline90" 
     tools:layout_constraintBottom_creator="1" 
     tools:layout_constraintLeft_creator="1" 
     tools:layout_constraintRight_creator="1" /> 

    <ScrollView 
     android:id="@+id/scrollView2" 
     android:layout_width="0dp" 
     android:layout_height="0dp" 
     android:layout_marginBottom="0dp" 
     android:layout_marginTop="0dp" 
     android:fillViewport="true" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintHorizontal_bias="0.0" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toTopOf="@+id/horGuideline10"> 

     <android.support.constraint.ConstraintLayout 
      android:layout_width="match_parent" 
      android:layout_height="400dp"> 


      <android.support.constraint.Guideline 
       android:id="@+id/verGuideline20" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" 
       app:layout_constraintGuide_percent="0.2" 
       tools:layout_editor_absoluteX="72dp" 
       tools:layout_editor_absoluteY="206dp" /> 

      <android.support.constraint.Guideline 
       android:id="@+id/verGuideline55" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" 
       app:layout_constraintGuide_percent="0.55" 
       tools:layout_editor_absoluteX="198dp" 
       tools:layout_editor_absoluteY="206dp" /> 

      <android.support.constraint.Guideline 
       android:id="@+id/verGuideline90" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" 
       app:layout_constraintGuide_percent="0.9" 
       tools:layout_editor_absoluteX="324dp" 
       tools:layout_editor_absoluteY="206dp" /> 

      <android.support.constraint.Guideline 
       android:id="@+id/horGuideline10in" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" 
       app:layout_constraintGuide_percent="0.1" 
       tools:layout_editor_absoluteX="0dp" 
       tools:layout_editor_absoluteY="233dp" /> 

      <android.support.constraint.Guideline 
       android:id="@+id/horGuideline20" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" 
       app:layout_constraintGuide_percent="0.2" 
       tools:layout_editor_absoluteX="0dp" 
       tools:layout_editor_absoluteY="260dp" /> 

      <android.support.constraint.Guideline 
       android:id="@+id/horGuideline28" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" 
       app:layout_constraintGuide_percent="0.28" 
       tools:layout_editor_absoluteX="0dp" 
       tools:layout_editor_absoluteY="282dp" /> 

      <android.support.constraint.Guideline 
       android:id="@+id/horGuideline38" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" 
       app:layout_constraintGuide_percent="0.38" 
       tools:layout_editor_absoluteX="0dp" 
       tools:layout_editor_absoluteY="309dp" /> 

      <TextView 
       android:id="@+id/needs_search_title_text" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="16dp" 
       android:layout_marginStart="16dp" 
       android:text="@string/service_request_title_text" 
       android:textColor="@color/ANDROID_DARK_GRAY" 
       android:textSize="@dimen/title_text_size" 
       app:layout_constraintBaseline_toBaselineOf="@+id/needs_search_title_edit" 
       app:layout_constraintLeft_toLeftOf="parent" 
       app:layout_constraintRight_toLeftOf="@+id/verGuideline20" /> 

      <EditText 
       android:id="@+id/needs_search_title_edit" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_marginEnd="8dp" 
       android:layout_marginRight="8dp" 
       android:layout_marginTop="8dp" 
       android:ems="10" 
       android:hint="@string/service_request_title_explanation_text" 
       android:inputType="textPersonName" 
       android:textColorHint="@color/ANDROID_DARK_GRAY" 
       app:layout_constraintBottom_toTopOf="@+id/horGuideline10in" 
       app:layout_constraintHorizontal_bias="0.0" 
       app:layout_constraintLeft_toLeftOf="@+id/verGuideline20" 
       app:layout_constraintRight_toRightOf="parent" 
       app:layout_constraintTop_toTopOf="parent" 
       app:layout_constraintVertical_bias="0.0" /> 

      <ImageView 
       android:id="@+id/iconLocation" 
       android:layout_width="0dp" 
       android:layout_height="0dp" 
       android:layout_marginBottom="8dp" 
       android:layout_marginLeft="16dp" 
       android:layout_marginStart="16dp" 
       android:layout_marginTop="8dp" 
       android:contentDescription="@string/service_request_location_icon_contentDescription" 
       app:layout_constraintBottom_toTopOf="@+id/horGuideline20" 
       app:layout_constraintHorizontal_bias="0.0" 
       app:layout_constraintLeft_toLeftOf="parent" 
       app:layout_constraintRight_toLeftOf="@+id/verGuideline20" 
       app:layout_constraintTop_toTopOf="@+id/horGuideline10in" 
       app:layout_constraintVertical_bias="0.454" 
       app:srcCompat="@drawable/ic_location_on_gray_24dp" /> 

      <EditText 
       android:id="@+id/service_request_address_editText" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_marginEnd="16dp" 
       android:layout_marginRight="16dp" 
       android:layout_marginTop="8dp" 
       android:ems="10" 
       android:hint="@string/service_request_location_text" 
       android:inputType="textPersonName" 
       android:textColorHint="@color/ANDROID_DARK_GRAY" 
       android:textSize="@dimen/size_text_button" 
       app:layout_constraintLeft_toRightOf="@+id/iconLocation" 
       app:layout_constraintRight_toRightOf="parent" 
       app:layout_constraintTop_toTopOf="@+id/horGuideline10in" /> 

      <ImageView 
       android:id="@+id/iconDecribeText" 
       android:layout_width="0dp" 
       android:layout_height="0dp" 

       android:layout_marginLeft="16dp" 
       android:layout_marginStart="16dp" 
       android:contentDescription="@string/service_request_text_contentDescription" 
       app:layout_constraintBottom_toTopOf="@+id/horGuideline38" 
       app:layout_constraintHorizontal_bias="0.0" 
       app:layout_constraintLeft_toLeftOf="parent" 
       app:layout_constraintRight_toLeftOf="@+id/verGuideline20" 
       app:layout_constraintTop_toTopOf="@+id/horGuideline28" 
       app:srcCompat="@drawable/ic_short_text_gray_24dp" /> 

      <EditText 
       android:id="@+id/needs_search_description_edit" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_marginEnd="16dp" 
       android:layout_marginRight="16dp" 
       android:layout_marginTop="8dp" 
       android:ems="10" 
       android:hint="@string/service_request_small_text_explanation" 
       android:inputType="textMultiLine" 
       android:textColorHint="@color/ANDROID_DARK_GRAY" 
       android:textSize="@dimen/size_text_button" 
       app:layout_constraintHorizontal_bias="0.0" 
       app:layout_constraintLeft_toLeftOf="@+id/verGuideline20" 
       app:layout_constraintRight_toRightOf="parent" 
       app:layout_constraintTop_toTopOf="@+id/horGuideline28" /> 

      <Button 
       android:id="@+id/needs_search_address_locate_btn" 
       android:layout_width="0dp" 
       android:layout_height="0dp" 
       android:alpha="0.5" 
       android:background="@android:drawable/dialog_holo_light_frame" 
       app:layout_constraintBottom_toTopOf="@+id/horGuideline28" 
       app:layout_constraintLeft_toLeftOf="@+id/verGuideline20" 
       app:layout_constraintRight_toLeftOf="@+id/verGuideline55" 
       app:layout_constraintTop_toTopOf="@+id/horGuideline20" 
       app:layout_constraintVertical_bias="0.0" /> 

      <Button 
       android:id="@+id/needs_search_address_home_btn" 
       android:layout_width="0dp" 
       android:layout_height="0dp" 
       android:layout_marginEnd="8dp" 
       android:layout_marginRight="8dp" 
       android:alpha="0.5" 
       android:background="@android:drawable/dialog_holo_light_frame" 
       app:layout_constraintBottom_toTopOf="@+id/horGuideline28" 
       app:layout_constraintLeft_toLeftOf="@+id/verGuideline55" 
       app:layout_constraintRight_toLeftOf="@+id/verGuideline90" 
       app:layout_constraintTop_toTopOf="@+id/horGuideline20" 
       app:layout_constraintVertical_bias="0.0" /> 

      <android.support.v7.widget.RecyclerView 
       android:id="@+id/needs_search_images_recyclerview" 
       android:layout_width="0dp" 
       android:layout_height="0dp" 
       android:layout_marginBottom="0dp" 
       android:layout_marginEnd="16dp" 
       android:layout_marginLeft="16dp" 
       android:layout_marginRight="16dp" 
       android:layout_marginStart="16dp" 
       android:layout_marginTop="24dp" 
       android:focusable="false" 
       android:focusableInTouchMode="false" 
       app:layout_constraintBottom_toBottomOf="parent" 
       app:layout_constraintLeft_toLeftOf="parent" 
       app:layout_constraintRight_toRightOf="parent" 
       app:layout_constraintTop_toBottomOf="@+id/needs_search_description_edit" 
       tools:listitem="@layout/needs_search_big_image_list_item" /> 

     </android.support.constraint.ConstraintLayout> 
    </ScrollView> 

</android.support.constraint.ConstraintLayout> 

</com.flipboard.bottomsheet.BottomSheetLayout> 

回答

2

好吧,我剛剛發現與朋友的解決方案,首先我想刪除這個,但因爲其他人也許有同樣的問題,這裏是解決方案:

我只是刪除所有指南並重新構建,連接元素時不需要使用太多的指導。

有點幸運,因爲我在修改方向時修正了這個問題。

+0

隨着'layout_constraintWidth_percent'和可用性'layout_constraintHeight_percent'屬性與ConstraintLayout的兒童使用,你可以再次得到與您在使用指南的初始設計中相同的結果。 「ConstraintLayout」的文檔已更新以描述這些新屬性。 – ema3272

1

您需要創建在頂欄一個chain有以下限制

  • :在中間內容

    app:layout_constraintBottom_toTopOf="@+id/scrollView2" app:layout_constraintTop_toTopOf="parent"

  • app:layout_constraintBottom_toTopOf="@+id/needs_search_save_btn" app:layout_constraintTop_toBottomOf="@+id/actionbar"

  • 底部按鈕

    app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toBottomOf="@+id/scrollView2"

+0

這隻會刪除準則並連接元素,對吧? 如何保證每個人使用百分比而不使用靜態大小? – Canato

+0

是的,在你的問題中,你說過你想讓中間內容的滾動視圖保持頂部欄和底部按鈕始終可見。具有上述約束條件的鏈條將會這樣做。 – ema3272

+0

但是,這已經工作,事情是滾動功能不起作用,但我解決了從內部約束佈局刪除指導。感謝您的幫助= D – Canato