0

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

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

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

(我提供了具有所需布局的 iPhone 屏幕截图。我无法在 stackoverflow 上上传图像,所以我提供了图像 URL。)

提前致谢。

活动布局

<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();

}
4

0 回答 0