‘壹’ android怎么用viewpager实现轮播图循环
这里要补充一下,在这个项目中我把图片轮播写进了一个Viewholder里内嵌在了Recyclelistview里。但本文只介绍图片轮播部分的实现:
整体思路:使用handler的延时发送方法(sendEmptyMessageDelayed)实现在adapter中控制Viewpager图片轮播
具体实现分为三个部分:
http://blog.csdn.net/qq_22770457/article/details/51198688
‘贰’ android 怎么在轮播时实现多种动画效果,如第一张到第二张渐变,第二张到第三张旋转
Android系统自带的一个多页面管理控件,它可以实现子界面的自动切换:
首先 需要为ViewFlipper加入View
(1) 静态导入:在layout布局文件中直接导入
(2) 动态导入:addView()方法
ViewPlipper常用方法:
setInAnimation:设置View进入屏幕时候使用的动画
setOutAnimation:设置View退出屏幕时候使用的动画
showNext:调用该函数来显示ViewFlipper里面的下一个View
showPrevious:调用该函数来显示ViewFlipper里面的上一个View
setFlipInterval:设置View之间切换的时间间隔
startFlipping使用上面设置的时间间隔来开始切换所有的View,切换会循环进行
stopFlipping:停止View切换
讲了这么多,那么我们今天要实现的是什么呢?
(1) 利用ViewFlipper实现图片的轮播
(2) 支持手势滑动的ViewFlipper
我们需要先准备几张图片:把图片放进drawable中
创建两个动画:在res下面新建一个folder里面新建两个xml:
‘叁’ android图片轮播怎么实现
正常就可以实现的吧,因为这个图片还是比较轻松的,我都是使用的
‘肆’ android 轮播列表怎么实现
第一种:使用动画的方法实现:
这种发放需要:两个动画效果,一个布局,一个主类来实现,
public class IamgeTrActivity extends Activity {
/** Called when the activity is first created. */
public ImageView imageView;
public ImageView imageView2;
public Animation animation1;
public Animation animation2;
public TextView text;
public boolean juage = true;
public int images[] = new int[] { R.drawable.icon, R.drawable.expriment,
R.drawable.changer, R.drawable.dataline, R.drawable.preffitication };
public int count = 0;
public Handler handler = new Handler();
public Runnable runnable = new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
AnimationSet animationSet1 = new AnimationSet(true);
AnimationSet animationSet2 = new AnimationSet(true);
imageView2.setVisibility(0);
TranslateAnimation ta = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF,
-1f, Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, 0f);
ta.setDuration(2000);
animationSet1.addAnimation(ta);
animationSet1.setFillAfter(true);
ta = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1.0f,
Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF,
0f, Animation.RELATIVE_TO_SELF, 0f);
ta.setDuration(2000);
animationSet2.addAnimation(ta);
animationSet2.setFillAfter(true);
//iamgeView 出去 imageView2 进来
imageView.startAnimation(animationSet1);
imageView2.startAnimation(animationSet2);
imageView.setBackgroundResource(images[count % 5]);
count++;
imageView2.setBackgroundResource(images[count % 5]);
text.setText(String.valueOf(count));
if (juage)
handler.postDelayed(runnable, 6000);
Log.i(handler, handler);
}
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
imageView = (ImageView) findViewById(R.id.imageView);
imageView2 = (ImageView) findViewById(R.id.imageView2);
text=(TextView)findViewById(R.id.text);
text.setText(String.valueOf(count));
//将iamgeView先隐藏,然后显示
imageView2.setVisibility(4);
handler.postDelayed(runnable, 2000);
}
public void onPause() {
juage = false;
super.onPause();
}
}
android:orientation=vertical
android:layout_width=fill_parent
android:layout_height=fill_parent
android:id=@+id/rl>
android:id=@+id/imageView
android:layout_width=fill_parent
android:background=@drawable/icon
android:layout_below=@+id/rl
android:layout_height=120dp />
android:id=@+id/imageView2
android:layout_width=fill_parent
android:background=@drawable/expriment
android:layout_below=@+id/rl
android:layout_height=120dp />
android:id=@+id/text
android:layout_width=fill_parent
android:layout_height=wrap_content
android:layout_below=@id/imageView/>
第二种:使用ViewFlipper实现图片的轮播
Android系统自带的一个多页面管理控件,它可以实现子界面的自动切换:
首先 需要为ViewFlipper加入View
(1) 静态导入:在layout布局文件中直接导入
(2) 动态导入:addView()方法
ViewPlipper常用方法:
setInAnimation:设置View进入屏幕时候使用的动画
setOutAnimation:设置View退出屏幕时候使用的动画
showNext:调用该函数来显示ViewFlipper里面的下一个View
showPrevious:调用该函数来显示ViewFlipper里面的上一个View
setFlipInterval:设置View之间切换的时间间隔
startFlipping使用上面设置的时间间隔来开始切换所有的View,切换会循环进行
stopFlipping:停止View切换
‘伍’ android轮播怎么设置轮播一次
代码:
public class IamgeTrActivity extends Activity {
/** Called when the activity is first created. */
public ImageView imageView;
public ImageView imageView2;
public Animation animation1;
public Animation animation2;
public TextView text;
public boolean juage = true;
public int images[] = new int[] { R.drawable.icon, R.drawable.expriment,
R.drawable.changer, R.drawable.dataline, R.drawable.preffitication };
public int count = 0;
public Handler handler = new Handler();
public Runnable runnable = new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
AnimationSet animationSet1 = new AnimationSet(true);
AnimationSet animationSet2 = new AnimationSet(true);
imageView2.setVisibility(0);
TranslateAnimation ta = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF,
-1f, Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, 0f);
ta.setDuration(2000);
animationSet1.addAnimation(ta);
animationSet1.setFillAfter(true);
ta = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1.0f,
Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF,
0f, Animation.RELATIVE_TO_SELF, 0f);
ta.setDuration(2000);
animationSet2.addAnimation(ta);
animationSet2.setFillAfter(true);
//iamgeView 出去 imageView2 进来
imageView.startAnimation(animationSet1);
imageView2.startAnimation(animationSet2);
imageView.setBackgroundResource(images[count % 5]);
count++;
imageView2.setBackgroundResource(images[count % 5]);
text.setText(String.valueOf(count));
if (juage)
handler.postDelayed(runnable, 6000);
Log.i(handler, handler);
}
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
imageView = (ImageView) findViewById(R.id.imageView);
imageView2 = (ImageView) findViewById(R.id.imageView2);
text=(TextView)findViewById(R.id.text);
text.setText(String.valueOf(count));
//将iamgeView先隐藏,然后显示
imageView2.setVisibility(4);
handler.postDelayed(runnable, 2000);
}
public void onPause() {
juage = false;
super.onPause();
}
}
布局代码:
android:orientation=vertical
android:layout_width=fill_parent
android:layout_height=fill_parent
android:id=@+id/rl>
android:id=@+id/imageView
android:layout_width=fill_parent
android:background=@drawable/icon
android:layout_below=@+id/rl
android:layout_height=120dp />
android:id=@+id/imageView2
android:layout_width=fill_parent
android:background=@drawable/expriment
android:layout_below=@+id/rl
android:layout_height=120dp />
android:id=@+id/text
android:layout_width=fill_parent
android:layout_height=wrap_content
android:layout_below=@id/imageView/>
‘陆’ android 中怎么实现多图自动轮播中间放大的效果
1,顶部轮播图,自动轮播效果。
2,顶部的viewpager 可随着下拉图片有渐变大的效果。
使用方法:
1,带轮播图的自定义ScrollView ,在项目中的名字叫ViewPagerImageScrollView,主要是通过图片的matrix.postScale(scale, scale, imgHeight/2, 0); 这个来进行当大图片。
‘柒’ android开发fragment可以使用轮播图吗
1、Fragment和activity一样开发,在里面使用轮播图是可以的,具体写法和activity一样,fragment依附fragment,在fragment实现activity可以实现的
2、钊林it里面实现轮播图使用了FrameLyout布局,解决手势冲突的问题
‘捌’ android怎样实现广告的轮播图
android的广告轮播图,大多数都是使用viewpager+fragment一起使用,手动可以切换图片的展示
‘玖’ android 怎么实现viewpager的垂直方向的自动轮播
listview里嵌套了一个viewpager实现图片轮播, 这本身就是一个有问题的嵌套, 为什么要这样布局呢, 图片轮播的控件一搜一大堆都是开源的, 使用又超级超级的简单.
‘拾’ Android图片轮播效果的几种实现方法
<!DOCTYPEhtml>
<html>
<head>
<metacharset="utf-8">
<title>HelloMUI</title>
<metaname="viewport"content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<metaname="apple-mobile-web-app-capable"content="yes">
<metaname="apple-mobile-web-app-status-bar-style"content="black">
<!--标准mui.css-->
<linkrel="stylesheet"href="../css/mui.min.css">
<!--App自定义的css-->
<linkrel="stylesheet"type="text/css"href="../css/app.css"/>
</head>
<body>
<headerclass="mui-barmui-bar-nav">
<aclass="mui-action-backmui-iconmui-icon-left-navmui-pull-left"></a>
<h1class="mui-title">下方悬浮标题</h1>
</header>
<divclass="mui-content">
<ulclass="mui-table-viewmui-table-view-chevron">
<liid="switch"class="mui-table-view-cell">
定时轮播
<!--<divclass="mui-switch">
<divclass="mui-switch-handle"></div>
</div>-->
</li>
</ul>
<divid="slider"class="mui-slider">
<divclass="mui-slider-groupmui-slider-loop">
<!--额外增加的一个节点(循环轮播:第一个节点是最后一张轮播)-->
<divclass="mui-slider-itemmui-slider-item-plicate">
<ahref="#">
<imgsrc="../images/yuantiao.jpg">
<pclass="mui-slider-title">静静看这世界</p>
</a>
</div>
<divclass="mui-slider-item">
<ahref="#">
<imgsrc="../images/shuijiao.jpg">
<pclass="mui-slider-title">幸福就是可以一起睡觉</p>
</a>
</div>
<divclass="mui-slider-item">
<ahref="#">
<imgsrc="../images/muwu.jpg">
<pclass="mui-slider-title">想要一间这样的木屋,静静的喝咖啡</p>
</a>
</div>
<divclass="mui-slider-item">
<ahref="#">
<imgsrc="../images/cbd.jpg">
<pclass="mui-slider-title">ColorofSIPCBD</p>
</a>
</div>
<divclass="mui-slider-item">
<ahref="#">
<imgsrc="../images/yuantiao.jpg">
<pclass="mui-slider-title">静静看这世界</p>
</a>
</div>
<!--额外增加的一个节点(循环轮播:最后一个节点是第一张轮播)-->
<divclass="mui-slider-itemmui-slider-item-plicate">
<ahref="#">
<imgsrc="../images/shuijiao.jpg">
<pclass="mui-slider-title">幸福就是可以一起睡觉</p>
</a>
</div>
</div>
<divclass="mui-slider-indicatormui-text-right">
<divclass="mui-indicatormui-active"></div>
<divclass="mui-indicator"></div>
<divclass="mui-indicator"></div>
<divclass="mui-indicator"></div>
</div>
</div>
</div>
</body>
<scriptsrc="../js/mui.min.js"></script>
<script>
// alert("!!!!!");
varslider=mui("#slider");
slider.slider({
interval:5000
});
</script>
</html>