Android的手势拖动切换View.docxVIP

  • 6
  • 0
  • 约4.2千字
  • 约 6页
  • 2021-01-10 发布于天津
  • 举报
An droid 的手势拖动切换 View:ViewFlipper 项目中有需求实现,模仿 Anroid主界面的形式,实现 Gallery和View之间的切换,发现 ViewFlipper满足我的要求,演示如下: 首先是main .xml: view source O1.v?xml version=1.0 encoding=utf-8? 02.RelativeLayout xmlns:android= /apk/res/ an droid 03. an droid:layout_width=fill_pare nt 04. an droid:layout_height=fill_pare nt 05. vViewFlipper an droid:id=@+id/ViewFlipper01 06. an droid:layout_width=wrap_co nten t an droid:layout_height= wrap_co nte nt 07. Li nearLayout an droid:id=@+id/Li nearLayout01 08. an droid:layout_width=wrap_co nte nt an droid:layout_hei ght=wrap_co nte nt 09. vTextView android:text=第 1 屏” android:id=@+id/TextVi ew01 an droid:layout_width=wrap_co ntent an droid:layout _height=wrap_c onten t/TextView v/Lin earLayout Li nearLayout an droid:id=@+id/Li nearLayout02 an droid:layout_width=wrap_co nte nt an droid:layout_hei ght=wrap_co nte nt vTextView android:text= 第 2 屏android:id=@+id/TextVi ew02 an droid:layout_width=wrap_co ntent an droid:layout _height=wrap_c onten t/TextView v/Lin earLayout /ViewFlipper vGallery an droid:id=@+id/gallery an droid:backgrou nd=an droid:layout_width=fill_pare nt an droid:layout_height=60dp an droid:layout_alig nPare ntBottom=true an droid:layout_alig nPare ntLeft=true an droid:gravity=ce nter_vertical an droid:spaci ng=16dp / /RelativeLayout Java文件代码: print? Ol.private In teger[] mThumblds = { 02. R.drawable.sample_thumb_O, R.drawable.sample_thumb_1, 03. R.drawable.sample_thumb_2, R.drawable.sample_thumb_3, 04. R.drawable.sample_thumb_4, R.drawable.sample_thumb_5, 05. R.drawable.sample_thumb_6, R.drawable.sample_thumb_7}; 06. private ViewFlipper flipper; 07. private GestureDetector gestureDetector; 08. private Gallery g; 09. @Override public void onCreate(Bundle savedInstanceState) { super.o nCreate(savedl nsta nceState); setC on te ntView(R.layout.mai n); g=(Gallery)fi ndViewByld(R.id.gallery); g.setAdapter( new ImageAdapter(this)); g.setSelectio n(4); g.set On ItemSelectedListe ner(new Onl temSelectedListe ner(){ @Override pub

文档评论(0)

1亿VIP精品文档

相关文档