Android 如何创建动画展开菜单
我想创建动画菜单,如所附图像中所示 当按下圆形按钮(使用向上箭头)时,它将向上展开(如第二幅图所示)。注:图像绘制不按比例,请原谅 我的大致想法如下:Android 如何创建动画展开菜单,android,android-animation,android-view,Android,Android Animation,Android View,我想创建动画菜单,如所附图像中所示 当按下圆形按钮(使用向上箭头)时,它将向上展开(如第二幅图所示)。注:图像绘制不按比例,请原谅 我的大致想法如下: 在展开菜单中,第一行和第二行的视图相同 键入,因此我将为该视图创建布局文件 第三排是 这是另一种布局 使用容器(FrameLayout)作为圆的主体 ImageButton(带箭头的按钮) onCreate创建活动, 为容器充气,添加上述所有视图,但仅设置为可见 到第一行和圆形按钮 当圆形按钮按下时 切换,只需设置可见/不可见的其他视图
- 在展开菜单中,第一行和第二行的视图相同
键入,因此我将为该视图创建布局文件 - 第三排是 这是另一种布局李>
- 使用容器(FrameLayout)作为圆的主体 ImageButton(带箭头的按钮)
创建活动, 为容器充气,添加上述所有视图,但仅设置为可见 到第一行和圆形按钮李>onCreate
- 当圆形按钮按下时 切换,只需设置可见/不可见的其他视图
- 我的方法有什么问题吗?有没有好的教程李>
- 容器应该是框架布局还是其他李>
- 在设置其他可见/不可见视图时,如何创建真正展开和折叠的效果李>
public class SlidingDrawerActivity extends Activity implements OnClickListener {
Button slideButton,b1, b2,b3;
SlidingDrawer slidingDrawer;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sliding_drawer);
slideButton = (Button) findViewById(R.id.slideButton);
slidingDrawer = (SlidingDrawer) findViewById(R.id.SlidingDrawer);
b1 = (Button) findViewById(R.id.Button01);
b2 = (Button) findViewById(R.id.Button02);
b3 = (Button) findViewById(R.id.Button03);
b1.setOnClickListener(this);
b2.setOnClickListener(this);
b3.setOnClickListener(this);
slidingDrawer.setOnDrawerOpenListener(new OnDrawerOpenListener() {
@Override
public void onDrawerOpened() {
slideButton.setText("V");
}
});
slidingDrawer.setOnDrawerCloseListener(new OnDrawerCloseListener() {
@Override
public void onDrawerClosed() {
slideButton.setText("^");
}
});
}
@Override
public void onClick(View v) {
Button b = (Button)v;
Toast.makeText(SlidingDrawerActivity.this, b.getText() + " is Clicked :)", Toast.LENGTH_SHORT).show();
}
}
活动\u滑动\u抽屉.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Drag the control at the bottom"
android:textSize="20dp"
tools:context=".SlidingDrawerActivity" />
<SlidingDrawer
android:layout_alignParentBottom="true"
android:id="@+id/SlidingDrawer"
android:layout_width="wrap_content"
android:layout_height="250dip"
android:content="@+id/contentLayout"
android:handle="@+id/slideButton"
android:orientation="vertical"
android:padding="10dip" >
<Button
android:id="@+id/slideButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="^"
>
</Button>
<LinearLayout
android:id="@+id/contentLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dip" >
<Button
android:id="@+id/Button01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="Button 1" >
</Button>
<Button
android:id="@+id/Button02"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="Button 2" >
</Button>
<Button
android:id="@+id/Button03"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="Button 3" >
</Button>
</LinearLayout>
</SlidingDrawer>
</RelativeLayout>
查看这个伟大的库:
google play music中实现了相同的模式。tks,这也很棒,但我在第一篇文章中就将另一篇文章标记为答案。干杯