没有动画ViewFlipper? [英] No animation with ViewFlipper?

查看:121
本文介绍了没有动画ViewFlipper?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用ViewFlipper添加动画视图之间,如下面关于这个问题的教程。然而,它只是似乎并不想工作。它会更改页面,但我没有得到任何动画 - 即使我补充一个巨大的延迟push_left_in

I'm trying to use ViewFlipper to add an animation between views, as in following a tutorial on the subject. However, it just doesn't seem to want to work. It'll change the pages, but I get no animation -- even if I add a huge delay to push_left_in.

下面是我的onCreate:

Here's my onCreate:


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        viewFlipper = (ViewFlipper)findViewById(R.id.flipper);
        viewFlipper.setAnimation(AnimationUtils.loadAnimation(this, R.anim.push_left_in));
        mapView = (MapView)findViewById(R.id.mapView);
        mapView.setBuiltInZoomControls(true);
    }

push_left_in来自谷歌样品。这里的触发动作:

push_left_in comes from the Google samples. Here's the trigger action:


    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle item selection
        switch (item.getItemId()) {
        case R.id.button_map:
            viewFlipper.setDisplayedChild(0);
            return true;
        case R.id.button_conditions_general:
            viewFlipper.setDisplayedChild(1);
            return true;
(etc)

和我的布局:



<?xml version="1.0" encoding="utf-8"?>

<LinearLayout android:id="@+id/mainlayout"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              xmlns:android="http://schemas.android.com/apk/res/android">

  <ViewFlipper android:id="@+id/flipper"
               android:layout_width="fill_parent"
               android:layout_height="fill_parent">  

    <view class="com.google.android.maps.MapView"
          android:id="@+id/mapView"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:clickable="true"
          android:apiKey="MY_API_KEY"
          />

    <TableLayout
                 android:layout_width="fill_parent"
                 android:layout_height="fill_parent"
                 android:background="#ffffff"
                 android:stretchColumns="1"
                 >
      <TableRow>
        <TextView android:id="@+id/field1"
                  android:layout_column="1"        
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:textColor="#000000"
                  android:textStyle="bold"
                  android:textSize="18px"
                  android:text="@string/field1"
                  >
        </TextView>
        <EditText android:text="100"
                  android:id="@+id/field2"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content">
        </EditText>
        <TextView android:id="@+id/field3"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:textColor="#000000"
                  android:textStyle="bold"
                  android:textSize="18px"
                  android:text="%"
                  >
        </TextView>
      </TableRow>
    </TableLayout>

  </ViewFlipper>
</LinearLayout>


思考?

推荐答案

尝试设置你的动画中的XML文件,而不是。

Try setting your animations in the xml file instead.

  <ViewFlipper android:id="@+id/flipper"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent"
           android:inAnimation="@anim/push_left_in"> 

这篇关于没有动画ViewFlipper?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆