2017-12-05 13 views
1

ScrollView 내부에서 ConstraintLayout으로 스크롤 가능한 활동을 만들려고합니다.ScrollView 하단의 빈 공간

Supposed to be like this

그러나 대신에 거기 아무것도 표시되지 않습니다 안드로이드 스튜디오 청사진에 바닥

Empty Space

에서 빈 공간을 보여줍니다.

<ScrollView 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:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:clipToPadding="false" 
android:layout_weight="1" 
android:fillViewport="true"> 

<android.support.constraint.ConstraintLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    tools:context="com.bonecadetrapo.imagensprincipal" 
    tools:layout_editor_absoluteX="0dp" 
    tools:layout_editor_absoluteY="25dp"> 

    <android.support.constraint.Guideline 
     android:id="@+id/guideline10" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     app:layout_constraintGuide_begin="929dp" /> 

    <android.support.v7.widget.CardView 
     android:id="@+id/cardview1" 
     android:layout_width="164dp" 
     android:layout_height="197dp" 
     android:layout_marginBottom="300dp" 
     android:layout_marginStart="17dp" 
     android:layout_marginTop="8dp" 
     android:clickable="true" 
     android:elevation="3dp" 
     android:focusable="true" 
     android:foreground="?android:selectableItemBackground" 
     app:layout_constraintBottom_toTopOf="@+id/guideline10" 
     app:layout_constraintStart_toStartOf="parent" 
     app:layout_constraintTop_toTopOf="@+id/guideline3" 
     app:layout_constraintVertical_bias="0.0"> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <ImageView 
       android:id="@+id/thumbnail" 
       android:layout_width="164dp" 
       android:layout_height="170dp" 
       android:layout_marginLeft="3dp" 
       android:layout_marginRight="3dp" 
       android:layout_marginTop="3dp" 
       android:background="?attr/selectableItemBackgroundBorderless" 
       android:clickable="true" 
       android:scaleType="centerInside" 
       app:srcCompat="@drawable/one" /> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_alignParentBottom="true" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentStart="true" 
       android:layout_below="@id/thumbnail" 
       android:paddingLeft="10dp" 
       android:paddingRight="10dp" 
       android:paddingTop="0dp" 
       android:text="example 1" /> 

     </RelativeLayout> 
    </android.support.v7.widget.CardView> 

    <android.support.v7.widget.CardView 
     android:id="@+id/cardview2" 
     android:layout_width="164dp" 
     android:layout_height="197dp" 
     android:layout_marginBottom="300dp" 
     android:layout_marginEnd="24dp" 
     android:layout_marginStart="17dp" 
     android:layout_marginTop="8dp" 
     android:clickable="true" 
     android:elevation="3dp" 
     android:focusable="true" 
     android:foreground="?android:selectableItemBackground" 
     app:layout_constraintBottom_toTopOf="@+id/guideline10" 
     app:layout_constraintEnd_toEndOf="parent" 
     app:layout_constraintHorizontal_bias="0.64" 
     app:layout_constraintStart_toStartOf="@+id/guideline5" 
     app:layout_constraintTop_toTopOf="@+id/guideline3" 
     app:layout_constraintVertical_bias="0.0"> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <ImageView 
       android:id="@+id/thumbnail2" 
       android:layout_width="164dp" 
       android:layout_height="170dp" 
       android:layout_marginLeft="3dp" 
       android:layout_marginRight="3dp" 
       android:layout_marginTop="3dp" 
       android:background="?attr/selectableItemBackgroundBorderless" 
       android:clickable="true" 
       android:scaleType="centerInside" 
       app:srcCompat="@drawable/two" /> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_alignParentBottom="true" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentStart="true" 
       android:layout_below="@id/thumbnail2" 
       android:paddingLeft="10dp" 
       android:paddingRight="10dp" 
       android:paddingTop="0dp" 
       android:text="example 2" /> 

     </RelativeLayout> 
    </android.support.v7.widget.CardView> 

    <android.support.v7.widget.CardView 
     android:id="@+id/cardview5" 
     android:layout_width="164dp" 
     android:layout_height="160dp" 
     android:layout_marginBottom="170dp" 
     android:layout_marginEnd="8dp" 
     android:layout_marginLeft="16dp" 
     android:layout_marginStart="8dp" 
     android:layout_marginTop="24dp" 
     android:clickable="true" 
     android:elevation="3dp" 
     android:focusable="true" 
     android:foreground="?android:selectableItemBackground" 
     app:layout_constraintBottom_toTopOf="@+id/guideline10" 
     app:layout_constraintEnd_toEndOf="parent" 
     app:layout_constraintHorizontal_bias="0.039" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintStart_toStartOf="parent" 
     app:layout_constraintTop_toBottomOf="@+id/cardview3" 
     app:layout_constraintVertical_bias="0.0"> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <ImageView 
       android:id="@+id/thumbnail5" 
       android:layout_width="164dp" 
       android:layout_height="130dp" 
       android:layout_marginLeft="6dp" 
       android:layout_marginRight="6dp" 
       android:layout_marginTop="6dp" 
       android:adjustViewBounds="false" 
       android:background="?attr/selectableItemBackgroundBorderless" 
       android:clickable="true" 
       android:cropToPadding="false" 
       android:scaleType="fitXY" 
       app:srcCompat="@drawable/exampletwo" /> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_alignParentBottom="true" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentStart="true" 
       android:layout_below="@id/thumbnail5" 
       android:paddingLeft="10dp" 
       android:paddingRight="10dp" 
       android:paddingTop="0dp" 
       android:text="Example 2" /> 

     </RelativeLayout> 
    </android.support.v7.widget.CardView> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="384dp" 
     android:layout_height="wrap_content" 
     android:paddingTop="@dimen/appbar_padding_top" 
     android:theme="@style/AppTheme.Negocio"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="?attr/colorPrimary" 
      app:layout_scrollFlags="scroll|enterAlways" 
      app:popupTheme="@style/AppTheme.Negocio" 
      app:title="Negocio"> 

     </android.support.v7.widget.Toolbar> 

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

    <android.support.constraint.Guideline 
     android:id="@+id/guideline3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     app:layout_constraintGuide_percent="0.06" /> 

    <android.support.constraint.Guideline 
     android:id="@+id/guideline5" 
     android:layout_width="wrap_content" 
     android:layout_height="929dp" 
     android:orientation="vertical" 
     app:layout_constraintGuide_begin="204dp" /> 

    <android.support.constraint.Guideline 
     android:id="@+id/guideline6" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     app:layout_constraintGuide_end="17dp" /> 
</android.support.constraint.ConstraintLayout> 

것은 내가 안드로이드 스튜디오 베타 7 오레오을 사용하고 있습니다 :

내 XML이있다. Google에서 모든 솔루션을 시도했지만 아무 것도 작동하지 않았습니다.

+0

을 사용하여 고정? –

+0

@ RobertoMartucci 동일한 결과가 나타납니다 –

+1

게시 한 두 이미지의 차이점을 볼 수 없습니다. – kalabalik

답변

1

는 나는이 코드를 당신의있는 ScrollView 및 ConstraintLayout 모두 높이 랩 콘텐츠를, 당신이 match_parent를 시도 않았다

<ScrollView 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:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:clipToPadding="false" 
    android:layout_weight="1" 
    android:fillViewport="true"> 

    <android.support.constraint.ConstraintLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     tools:context="com.bonecadetrapo.imagensprincipal" 
     tools:layout_editor_absoluteX="0dp" 
     tools:layout_editor_absoluteY="25dp"> 

     <android.support.constraint.Guideline 
      android:id="@+id/guideline10" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      app:layout_constraintGuide_begin="929dp" /> 

     <android.support.v7.widget.CardView 
      android:id="@+id/cardview1" 
      android:layout_width="164dp" 
      android:layout_height="197dp" 
      android:layout_marginBottom="300dp" 
      android:layout_marginStart="17dp" 
      android:layout_marginTop="8dp" 
      android:clickable="true" 
      android:elevation="3dp" 
      android:focusable="true" 
      android:foreground="?android:selectableItemBackground" 
      app:layout_constraintBottom_toTopOf="@+id/guideline10" 
      app:layout_constraintStart_toStartOf="parent" 
      app:layout_constraintTop_toTopOf="@+id/guideline3" 
      app:layout_constraintVertical_bias="0.0" 
      android:layout_marginLeft="17dp"> 

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 

       <ImageView 
        android:id="@+id/thumbnail" 
        android:layout_width="164dp" 
        android:layout_height="170dp" 
        android:layout_marginLeft="3dp" 
        android:layout_marginRight="3dp" 
        android:layout_marginTop="3dp" 
        android:background="?attr/selectableItemBackgroundBorderless" 
        android:clickable="true" 
        android:scaleType="centerInside" 
        app:srcCompat="@drawable/one" /> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_alignParentBottom="true" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" 
        android:layout_below="@id/thumbnail" 
        android:paddingLeft="10dp" 
        android:paddingRight="10dp" 
        android:paddingTop="0dp" 
        android:text="example 1" /> 

      </RelativeLayout> 

      <android.support.constraint.Guideline 
       android:id="@+id/guideline6" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" 
       app:layout_constraintGuide_end="17dp" /> 
     </android.support.v7.widget.CardView> 

     <android.support.v7.widget.CardView 
      android:id="@+id/cardview2" 
      android:layout_width="164dp" 
      android:layout_height="197dp" 
      android:layout_marginBottom="300dp" 
      android:layout_marginEnd="24dp" 
      android:layout_marginStart="17dp" 
      android:layout_marginTop="8dp" 
      android:clickable="true" 
      android:elevation="3dp" 
      android:focusable="true" 
      android:foreground="?android:selectableItemBackground" 
      app:layout_constraintBottom_toTopOf="@+id/guideline10" 
      app:layout_constraintEnd_toEndOf="parent" 
      app:layout_constraintHorizontal_bias="0.64" 
      app:layout_constraintStart_toStartOf="@+id/guideline5" 
      app:layout_constraintTop_toTopOf="@+id/guideline3" 
      app:layout_constraintVertical_bias="0.0" 
      android:layout_marginRight="24dp" 
      android:layout_marginLeft="17dp"> 

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 

       <ImageView 
        android:id="@+id/thumbnail2" 
        android:layout_width="164dp" 
        android:layout_height="170dp" 
        android:layout_marginLeft="3dp" 
        android:layout_marginRight="3dp" 
        android:layout_marginTop="3dp" 
        android:background="?attr/selectableItemBackgroundBorderless" 
        android:clickable="true" 
        android:scaleType="centerInside" 
        app:srcCompat="@drawable/two" /> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_alignParentBottom="true" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" 
        android:layout_below="@id/thumbnail2" 
        android:paddingLeft="10dp" 
        android:paddingRight="10dp" 
        android:paddingTop="0dp" 
        android:text="example 2" /> 

      </RelativeLayout> 
     </android.support.v7.widget.CardView> 

     <android.support.v7.widget.CardView 
      android:id="@+id/cardview5" 
      android:layout_width="164dp" 
      android:layout_height="160dp" 
      android:layout_marginEnd="8dp" 
      android:layout_marginLeft="16dp" 
      android:layout_marginStart="8dp" 
      android:layout_marginTop="24dp" 
      android:clickable="true" 
      android:elevation="3dp" 
      android:focusable="true" 
      android:foreground="?android:selectableItemBackground" 
      app:layout_constraintBottom_toTopOf="@+id/guideline10" 
      app:layout_constraintEnd_toEndOf="parent" 
      app:layout_constraintHorizontal_bias="0.039" 
      app:layout_constraintLeft_toLeftOf="parent" 
      app:layout_constraintStart_toStartOf="parent" 
      app:layout_constraintTop_toBottomOf="@+id/cardview2" 
      app:layout_constraintVertical_bias="0.0"> 

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 

       <ImageView 
        android:id="@+id/thumbnail5" 
        android:layout_width="164dp" 
        android:layout_height="130dp" 
        android:layout_marginLeft="6dp" 
        android:layout_marginRight="6dp" 
        android:layout_marginTop="6dp" 
        android:adjustViewBounds="false" 
        android:background="?attr/selectableItemBackgroundBorderless" 
        android:clickable="true" 
        android:cropToPadding="false" 
        android:scaleType="fitXY" 
        app:srcCompat="@drawable/exampletwo" /> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_alignParentBottom="true" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" 
        android:layout_below="@id/thumbnail5" 
        android:paddingLeft="10dp" 
        android:paddingRight="10dp" 
        android:paddingTop="0dp" 
        android:text="Example 2" /> 

      </RelativeLayout> 
     </android.support.v7.widget.CardView> 

     <android.support.design.widget.AppBarLayout 
      android:id="@+id/appbar" 
      android:layout_width="384dp" 
      android:layout_height="wrap_content"> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_weight="1" 
       android:background="?attr/colorPrimary" 
       app:layout_scrollFlags="scroll|enterAlways" 
       app:title="Negocio"> 

      </android.support.v7.widget.Toolbar> 

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

     <android.support.constraint.Guideline 
      android:id="@+id/guideline3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      app:layout_constraintGuide_percent="0.06" /> 

     <android.support.constraint.Guideline 
      android:id="@+id/guideline5" 
      android:layout_width="wrap_content" 
      android:layout_height="929dp" 
      android:orientation="vertical" 
      app:layout_constraintGuide_begin="204dp" /> 

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

그것이 당신을 위해 일하면 친절하게 투표하십시오! –

+0

불행히도 여전히 바닥에 빈 공간이 표시됩니다. –

+0

마지막 cardview에서 'app : layout_constraintTop_toBottomOf = "@ + id/cardview3"'과 같은 줄이 있지만 cardview3이라는 이름으로보기가 없습니다. 이렇게 이것을 마지막 카드보기 위에있는 cardview의 id로 변경하면, 그보기 아래에 오게됩니다. 이것은 이제 빈 공간입니다. –