`
759235384
  • 浏览: 3947 次
  • 性别: Icon_minigender_2
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

在launcher 2.1上实现2.2的屏幕标记

阅读更多
转自:http://www.cnmsdn.com/html/201101/1296289422ID9358.html


Launcher2.2自带了屏幕标记,他是分了两块,分别为在左下角和右下角。

  1) 每一块为一个imageview,在配置文件Launcher.xml中直接添加

  < ImageView

  android:id="@+id/previous_screen"

  android:layout_width="93dip"

  android:layout_height="20dip"

  android:layout_gravity="bottom|left"

  android:layout_marginLeft="6dip"

  android:scaleType="center"

  android:src="@drawable/home_arrows_left"

  android:onClick="previousScreen"

  android:focusable="true"

  android:clickable="true" />

  其中android:onClick="previousScreen"引用了一个名为previousScreen的方法,在Launcher.java类中定义。

  其它一些用到的配置文件及图片可以直接从2.2的工程中拷贝。

  2) 在Launcher的setupViews方法中获取配置文件中添加的imageview:

  mPreviousView = (ImageView) dragLayer.findViewById(R.id.previous_screen);

  Drawable previous = mPreviousView.getDrawable();

  mPreviousView.setHapticFeedbackEnabled(false);

  mPreviousView.setOnLongClickListener(this);

  3) 在Launcher的setupViews方法后添加previousScreen方法:

  public void previousScreen(View v) {

  mWorkspace.scrollLeft();

  }

  4) 在workspace的setIndicators方法中添加:

  mPreviousIndicator = previous;

  mNextIndicator = next;

  setCurrentScreen方法中添加:

  mPreviousIndicator.setLevel(mCurrentScreen);

  mNextIndicator.setLevel(mCurrentScreen);
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics