如何像打开门一样旋转视图?

时间:2014-07-24 07:01:26

标签: android android-animation android-spinner objectanimator

我想创建一个布局,其中包含一些微调器,用于从列表中选择值。

工作:当我点击微调器时,布局应该像打开门一样旋转,值列表应该从屏幕的左边缘出现。从列表中选择一个值后,布局应该再次旋转,看起来像关闭门,值列表应该到屏幕的左边缘,选择的值应该出现在微调器上。

图片链接: https://onedrive.live.com/?cid=2CC6E5A8B70750DE&id=2CC6E5A8B70750DE!751&authkey=!AIu144d4FjBpiVc&v=3

(我正在提供具有所需布局的iPhone屏幕截图。我无法在stackoverflow上传图像,因此我提供了图片网址。)

提前致谢。

活动布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/llRegistration"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_alignParentLeft="true"
android:background="#1AA0B0"
android:gravity="left" >
<Button
    android:id="@+id/btnState"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Select One" />

对象动画师(flip_on_vertical.xml)

<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:propertyName="rotationY"
android:valueFrom="0"
android:valueTo="50"
android:valueType="floatType" >

代码

 LinearLayout linearLayoutRegistration;
 Button btnSelect;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_new);

    linearLayoutRegistration = (LinearLayout) findViewById(R.id.llRegistration);
    btnSelect = (Button) findViewById(R.id.btnState);
    btnSelect.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            flipOnVertical(linearLayoutRegistration);
        }
    });
}

public void flipOnVertical(View view) {
    View image = findViewById(view.getId());

    Animator anim = AnimatorInflater.loadAnimator(this,
            R.animator.flip_on_vertical);
    anim.setTarget(image);
    anim.start();

}

0 个答案:

没有答案
相关问题