『壹』 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>