【问题标题】:Constraintlayout inside scrollview ,always guideline height varies滚动视图内的约束布局,总是参考线高度变化
【发布时间】:2018-11-27 09:16:57
【问题描述】:

NestedScrollView 内的约束布局,总是参考线高度变化。

指南高度百分比效果不佳。它取决于 recylerview 和其他视图内容。如何解决这个问题,在滚动视图内固定的指南高度

代码

 <android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"

android:fillViewport="true"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.constraint.ConstraintLayout 
  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="match_parent"
     android:id="@+id/top_clay"
    android:paddingLeft="0dp"
    android:paddingRight="0dp">

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

              <TextView

        android:id="@+id/vpager_dsv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        app:layout_constraintTop_toBottomOf="@+id/guideline_graph" />


       <android.support.v7.widget.RecyclerView
        android:id="@+id/rcv"
        android:layout_width="0dp"

        android:layout_height="wrap_content"
        android:layout_marginBottom="20dp"
        android:nestedScrollingEnabled="false"
        android:layout_marginTop="10dp"

        android:layout_marginLeft="10dp"

        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintStart_toStartOf="parent"


        app:layout_constraintTop_toBottomOf="@+id/guideline_graph"> 
   </android.support.v7.widget.RecyclerView>
 </android.support.constraint.ConstraintLayout>

【问题讨论】:

  • 当您说“指南高度百分比效果不佳”时,您到底是什么意思?你能发布一些图片来描述你所看到的吗?
  • 问题是scrollview里面的constraintlayout,scorllview的高度取决于receylerview的内容。所以指南高度也有所不同。有什么办法解决这个问题?
  • 嘿,你找到解决办法了吗?

标签: android android-layout android-constraintlayout


【解决方案1】:

{@code Guideline}{@see Guideline} 对象允许您创建 * 相对于定位的水平和垂直指南 {@code ConstraintLayout} 容器。

以上文字是从约束布局文档中复制而来的。指南根据容器大小定位。因此,根据约束布局指南内的视图大小,其位置会有所不同。

我认为这种行为是意料之中的。

【讨论】:

  • 滚动视图内的指南只有这个问题。无论如何要修复它
  • 我认为没有办法解决这个问题。因为在滚动视图中基于子高度容器大小不同。
  • 你能说出你的 UI 应该是什么样子吗?
猜你喜欢
  • 2020-07-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-09
  • 1970-01-01
  • 2016-12-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多