Android 图片横向滚动效果(2)

<ImageButton android:id="@+id/property_doc" android:visibility="gone"
      android:layout_width="59.0dip" android:layout_height="51.0dip"
      android:scaleType="centerInside" android:background="@drawable/icon">
     </ImageButton>

<LinearLayout android:layout_height="51.0dip"
      android:layout_width="1sp" android:background="#000000">
     </LinearLayout>

<ImageButton android:id="@+id/sort_doc"
      android:layout_width="59.0dip" android:layout_height="51.0dip"
      android:scaleType="centerInside" android:background="@drawable/icon">
     </ImageButton>


     <LinearLayout android:layout_height="51.0dip"
      android:layout_width="1sp" android:background="#000000">
     </LinearLayout>

<ImageButton android:id="@+id/send_doc"
      android:layout_width="59.0dip" android:layout_height="51.0dip"
      android:scaleType="centerInside" android:background="@drawable/icon">
     </ImageButton>
    </LinearLayout>
    <ImageView android:layout_width="wrap_content"
     android:layout_height="51.0dip" android:src="@drawable/icon" />

</LinearLayout>
  </HorizontalScrollView>
</LinearLayout>

二、MainActivity类中的代码:

package com.cn.android;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.OvershootInterpolator;
import android.widget.ImageButton;
import android.widget.LinearLayout;

public class MainActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

setContentView(R.layout.main);
        //打开项目整个队列图进入的效果动画


        LinearLayout toolbarLayout = (LinearLayout) findViewById(R.id.toolbar_items);
        Animation animation = AnimationUtils
           .loadAnimation(this, R.anim.toolbar);
        animation.setInterpolator(new OvershootInterpolator());
        // animation.setInterpolator(new BounceInterpolator());
        toolbarLayout.startAnimation(animation);
        initToolbarBtn();//初始化ImageButton
    }


    //响应按钮点击事件  


    private void initToolbarBtn() {
        ImageButton backmain = (ImageButton) findViewById(R.id.back_main);
        backmain.setOnClickListener(new View.OnClickListener() {
  
            public void onClick(View v) {
                 Intent i = getIntent();
                 setResult(RESULT_CANCELED, i);
                 finish();
           }
   });

ImageButton newdoc = (ImageButton) findViewById(R.id.new_doc);
  newdoc.setOnClickListener(new View.OnClickListener() {
  
   public void onClick(View v) {
    //写上自己要实现的方法
   }
  });
    }
}

三、自定义动画实现从左向右滚动:在res下面建个文件夹名字anim,下建立toolbar.xml<?xml version="1.0" encoding="UTF-8"?>;目的是打开程序画面的时候有个动画的效果
<translate
 android:duration="700" android:fromXDelta="100.0%p" android:toXDelta="0.0"
 xmlns:android="http://schemas.android.com/apk/res/android" />

linux

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwjwzw.html