将视图可见性设置为 View.GONE,使其不可见,仍然占用 space
Setting the View visibility to View.GONE, makes it invisible, still takes up space
我有一个视图要折叠,所以我把可见性设置为View.GONE视图变得不可见,但它仍然占用space。
我不知道它可能是什么,有人有想法吗?
这是之前的一张图片(视图 D):
这是(视图 D)之后的图像:
布局如下:
<?xml version="1.0" encoding="utf-8"?>
<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="match_parent"
android:background="@color/mainColor"
android:clipToPadding="false"
android:fillViewport="false"
android:scrollbars="none">
<android.support.constraint.ConstraintLayout
android:id="@+id/options_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true">
<!-- other irrelevants views -->
<TextView
android:id="@+id/time_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="32dp"
android:fontFamily="sans-serif"
android:text="@string/toolbar_options_title_time"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/option_hexa_sorting" />
<com.development.mekanius.bounce.customElements.HexaRadioGroupView
android:id="@+id/option_hexa_time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/time_title" />
<Button
android:id="@+id/option_create_post"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="32dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/option_hexa_time" />
</android.support.constraint.ConstraintLayout>
提前致谢
首先很抱歉回复晚了,我一直卡在final上,时间不多了。
好的,问题完全是另外一回事了。
我正在使用 Spotify 的 Mobius 作为状态机:
https://github.com/spotify/mobius
它使用后台线程来消耗效果,因此对 UI 进行操作会出错。但由于某种原因,错误被抑制了(不在日志中,也没有抛出异常),所以我看到的只是视图不服从命令。
我得出这个结论,删除代码行直到某些东西起作用。
很老的时尚。
感谢所有试图提供帮助的人。
我花了几个小时调试为什么会发生这种情况,然后偶然发现了您的回答。我正在改变 Rx-Java 线程的可见性,该线程应该在主线程上运行但显然不是!做 view.post {..} 为我解决了这个问题!非常感谢
我有一个视图要折叠,所以我把可见性设置为View.GONE视图变得不可见,但它仍然占用space。
我不知道它可能是什么,有人有想法吗?
这是之前的一张图片(视图 D):
这是(视图 D)之后的图像:
布局如下:
<?xml version="1.0" encoding="utf-8"?>
<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="match_parent"
android:background="@color/mainColor"
android:clipToPadding="false"
android:fillViewport="false"
android:scrollbars="none">
<android.support.constraint.ConstraintLayout
android:id="@+id/options_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true">
<!-- other irrelevants views -->
<TextView
android:id="@+id/time_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="32dp"
android:fontFamily="sans-serif"
android:text="@string/toolbar_options_title_time"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/option_hexa_sorting" />
<com.development.mekanius.bounce.customElements.HexaRadioGroupView
android:id="@+id/option_hexa_time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/time_title" />
<Button
android:id="@+id/option_create_post"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="32dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/option_hexa_time" />
</android.support.constraint.ConstraintLayout>
提前致谢
首先很抱歉回复晚了,我一直卡在final上,时间不多了。
好的,问题完全是另外一回事了。
我正在使用 Spotify 的 Mobius 作为状态机:
https://github.com/spotify/mobius
它使用后台线程来消耗效果,因此对 UI 进行操作会出错。但由于某种原因,错误被抑制了(不在日志中,也没有抛出异常),所以我看到的只是视图不服从命令。
我得出这个结论,删除代码行直到某些东西起作用。
很老的时尚。
感谢所有试图提供帮助的人。
我花了几个小时调试为什么会发生这种情况,然后偶然发现了您的回答。我正在改变 Rx-Java 线程的可见性,该线程应该在主线程上运行但显然不是!做 view.post {..} 为我解决了这个问题!非常感谢