Android: 仿Launcher Workspace左右滑动控件
Android: 仿Launcher Workspace左右滑动控件
修改Launcher的Workspace,去掉Drag相关的操作,精简为一个支持左右滑动的控件
每屏中可以自由放置layout
主要的问题是对
@Override
public boolean dispathTouchEvent(MotionEvent ev) {}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {}
@Override
public boolean onTouchEvent(MotionEvent ev) {}
的理解,不然不好控制touch事件
代码贴上,其实没啥参考价值:
- <?xml version="1.0" encoding="utf-8"?>
- <com.mylauncher.Workspace
- xmlns:Android="http://schemas.android.com/apk/res/android"
- xmlns:launcher="http://schemas.android.com/apk/res/com.mylauncher"
- android:id="@+id/workspace"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:scrollbars="horizontal"
- android:fadeScrollbars="true"
- launcher:defaultScreen="0">
- <com.mylauncher.CellLayout android:background="#ff0000ff"
- android:id="@+id/cell1"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- >
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textSize="30sp"
- android:textStyle="bold"
- android:text="@string/screen1" />
- <Button
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textSize="30sp"
- android:textStyle="bold"
- android:text="@string/screen1" />
- </com.mylauncher.CellLayout>
- <com.mylauncher.CellLayout android:background="#ffff0000"
- android:id="@+id/cell2"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- >
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textSize="30sp"
- android:textStyle="bold"
- android:text="@string/screen2" />
- <Button
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textSize="30sp"
- android:textStyle="bold"
- android:text="@string/screen2" />
- </com.mylauncher.CellLayout>
- <com.mylauncher.CellLayout android:background="#ff00ff00"
- android:id="@+id/cell3"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- >
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textSize="30sp"
- android:textStyle="bold"
- android:text="@string/screen3" />
- <Button
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textSize="30sp"
- android:textStyle="bold"
- android:text="@string/screen3" />
- </com.mylauncher.CellLayout>
- </com.mylauncher.Workspace>
|
评论暂时关闭