我希望有一个视图从底部出现,并使用动画填充半个屏幕。在这个视图中,我会有很多个 ImageButton。
我可以编写从底部到半屏幕的动画,但之后我的视图就会填满整个屏幕。
我想要的效果如下图所示: 实际上,我得到的效果是这样的: XML 代码:
我想要的效果如下图所示: 实际上,我得到的效果是这样的: XML 代码:
<android.support.v4.widget.DrawerLayout
android:id="@+id/screen_dashboard" style="@style/drawer"
tools:openDrawer="start">
(...)
<TableLayout
android:id="@+id/hidden_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:visibility="gone" >
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageButton
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:onClick="slideUpDown" />
<ImageButton
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:onClick="slideUpDown" />
</TableRow>
</TableLayout>
</android.support.v4.widget.DrawerLayout>
Java代码:
public void slideUpDown(final View view) {
if (!isPanelShown()) {
// Show the panel
Animation bottomUp = AnimationUtils.loadAnimation(this, R.animator.bottom_up);
hiddenPanel.startAnimation(bottomUp);
hiddenPanel.setVisibility(View.VISIBLE);
}
else {
// Hide the Panel
Animation bottomDown = AnimationUtils.loadAnimation(this, R.animator.bottom_down);
hiddenPanel.startAnimation(bottomDown);
hiddenPanel.setVisibility(View.GONE);
}
}
private boolean isPanelShown() {
return hiddenPanel.getVisibility() == View.VISIBLE;
}
有没有人知道我该怎么做才能让我的视图仅填满半个屏幕?