How would I slide up (open) a hidden textview/layout without pushing a view/widget down?

huangapple go评论72阅读模式
英文:

How would I slide up (open) a hidden textview/layout without pushing a view/widget down?

问题

我有一个应用程序,在其中一个隐藏的线性布局应该打开,以显示一个带有用户信息的文本视图。打开/关闭线性布局的按钮位于手机屏幕底部。当我按下按钮时,按钮会被迫向下移动,超出视野,以便显示隐藏的布局。我想要的界面效果是,当我按下按钮时,隐藏的布局将使UI内容向上滑动,同时按钮保持在屏幕上的位置不变。当我再次点击按钮时,布局将关闭(向下滑动),将UI恢复到其原始位置。

我尝试了许多其他建议,这些建议在其他Stackoverflow链接上提出,在所有情况下,1) 隐藏布局从手机屏幕的页脚或页眉出现,2) 激活隐藏布局的按钮与隐藏部分相距足够远,无需将隐藏部分适应两个视图/小部件内,或者3) 我只是无法使隐藏的布局完全消失(即View.GONE不会删除布局的顶部部分)。有人能指导我找到一个能帮助我实现这种上下滑动UI的解决方案吗?下面是隐藏布局的代码(请参见图像进行可视化),如果需要查看XML文件以实现上下滑动,我也有这些文件。如果需要任何其他信息,请告诉我。

我感谢您的帮助!

英文:

I have an app in which a hidden linear layout is supposed to open to show a text view with user information. The button to open/close the linear layout is at the bottom of the phone screen. When I press the button, the button is forced down, out of view, to allow for the hidden layout. What I want the UI to do is when I press the button, the hidden layout will slide the UI contents up leaving the button where it is on the screen. And when I click the button again, the layout will close (slide down) bringing the UI back to it's original position.

I tried many of the other suggestions that have been presented on other Stackoverflow links and, in all cases, 1) the hidden layouts are coming up from the footer or header of the phone screen, 2) the button that activates the hidden layout is far enough removed from the hidden section that there is no need to fit the hidden section within two views/widgets, or 3) I just can't get the hidden layout to fully disappear (i.e. View.GONE doesn't remove the top section of the layout). Can anyone direct me to a solution that will help me slide up and down the UI in this way? The code below is for the hidden layout (see image for visual) and I have the XML files to slide up/down if there is a need to look at them. Let me know if there is a need for any additional information.

I appreciate the help!

[Image of hidden layer when layout slides open][1]
[1]: https://i.stack.imgur.com/le1Bc.png

          <LinearLayout
                android:id="@+id/transition_container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/hidden_textView_button_results"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/daily_bread_result"
                    android:layout_marginStart="35dp"
                    android:layout_marginEnd="35dp"
                    android:gravity="center"
                    android:paddingTop="100dp"
                    android:paddingBottom="100dp"
                    android:textAlignment="center"
                    android:textSize="32sp"
                    android:textStyle="bold"
                    android:text="Do ya see me?!?"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/cardView_editTexts"
                    app:layout_constraintBottom_toTopOf="@+id/cardView_CalculateDailyBread"/>

            </LinearLayout>

答案1

得分: 0

一切都包含在一个ScrollView中,是吗?所以听起来您想要使隐藏的布局可见,然后立即将隐藏布局的高度添加到ScrollView的滚动位置。

或者,您可以完全放弃按钮,只需在填写完所有EditText后立即显示该值。如果它们没有被填写,显示一条消息表示缺少信息。

英文:

Everything is contained within a ScrollView, yes? So it sounds like you want to make the hidden layout visible and then immediately add the height of the hidden layout to the scroll position of the ScrollView.

Or you could just ditch the button entirely and simply show the value as soon as all the EditTexts are filled out. And if they're not filled out, show a message saying that info is missing.

huangapple
  • 本文由 发表于 2020年8月27日 01:37:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/63602959.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定