我想执行布局的上移。幻灯片应从底部显示,其中包含一些文字。 以下是代码。构建时没有错误,但布局不能向上滑动。 活动调用扩展AppCompatActivity。无法在RelativeLayout上执行滑动动画
slide_up.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromYDelta="75%p"
android:toYDelta="100%p"
android:fillAfter="true"
android:duration="500" />
</set>
布局文件:
<LinearLayout>
<RelativeLayout
android:id="@+id/time"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:visibility="gone" />
</LinearLayout>
Activity.java
Animation bottomUp = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_up);
ViewGroup hiddenPanel = (ViewGroup)findViewById(R.id.time);
hiddenPanel.startAnimation(bottomUp);
hiddenPanel.setVisibility(View.VISIBLE);
这不起作用。你能提出一些其他解决方案吗?我想布局在底部与顶部100dp的高度。 – Nikhil
再次运气。我上面的代码中有任何错误?我应该将RelativeLayout更改为其他内容吗? – Nikhil
LinearLayout还可以添加 –