我想執行佈局的上移。幻燈片應從底部顯示,其中包含一些文字。 以下是代碼。構建時沒有錯誤,但佈局不能向上滑動。 活動調用擴展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還可以添加 –