【发布时间】:2014-09-27 03:49:20
【问题描述】:
我的相对布局具有三个按钮,1 个锚定在顶部(TopButton),一个在底部(BottomButton,一个将直接放置在顶部按钮下方或底部按钮上方( MiddleButton) 根据用户触摸我的按钮。
在每个按钮下,我放置了一个 ScrollView,然后在其中放置了一个 textView。我正在尝试创建一组侦听器,以便当用户单击其中一个按钮时,其他两个按钮 ScrollViews(及其 textViews)设置为View.GONE,并且按下的按钮将其 ScrollView 设置为View.Visible。
除了设置 ScrollViews 可见性之外,我还想根据按下的按钮通过简单的滑动动画(全部在屏幕上)将按钮的位置更改为三种设置之一:
TopButton pushed - (打开Activity,现在设置什么)这个按钮的scrollView是可见的,另外两个设置为gone,两个按钮都在底部屏幕。
MiddleButton push - ScrollView 1 和 3 将设置为消失,ScrollView 2 将可见,
MiddleButton将在TopButton下方向上滑动。所以顺序将是TopButton、MiddleButton、Scroll/TextView2、BottomButton。-
BottomButton pushed - ScrollViews 1 和 2 将设置为 Gone,3 将设置为 Visible,
BottomButton将向上滑动以显示 ScrollView 的最大空间。所以这个顺序是TopButton,MiddleButton,BottomButton,Scroll/TextView3<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/OverallLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:animateLayoutChanges="true" tools:context="${relativePackage}.${activityClass}" > <Button android:id="@+id/TopButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" /> <Button android:id="@+id/BottomButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" /> <Button android:id="@+id/MiddleButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_above="@id/BottomButton" /> <ScrollView android:id="@+id/Scroll1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_above="@id/MiddleButton" android:layout_below="@id/TopButton" android:visibility="visible" > <TextView android:id="@+id/textView1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" /> </ScrollView> <ScrollView android:id="@+id/Scroll2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_above="@id/BottomButton" android:layout_below="@id/MiddleButton" android:visibility="gone" > <TextView android:id="@+id/textView2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" /> </ScrollView> <ScrollView android:id="@+id/Scroll3" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_below="@id/BottomButton" android:visibility="gone" > <TextView android:id="@+id/textView3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" /> </ScrollView> </RelativeLayout>
我需要帮助确定 fromY 和 toY 值才能使这个移动动画正常工作。这些设置是什么?
【问题讨论】:
-
您有什么具体问题吗?
-
我将如何制作这些动画?我从这个开始:
<set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:fromXDelta="0" android:fromYDelta="-1000" android:duration="1500"/> </set>但它会将按钮冲到顶部,然后慢慢将其拖到开始的位置。
标签: java android android-layout android-animation android-button