StandOut 是一个在Android应用中创建浮动窗口的框架,使用该框架可以方便的创建各种浮动窗口。可以指定窗口大小、放置的位置、是否可以拖动、是否可以最小化、可以在通知栏显示提示等等。
项目如图:
主要项目StandOut:
public abstract class StandOutWindow extends Service //扩展这个类可以轻松地创建和管理的浮动出色的窗口 这是一个后台服务通过Window产生布局视图。
public class WindowCache //窗体缓存
public class Window extends FrameLayout //浮动窗体视图
实例项目FloatingFolders:
public class AppAdapter extends ArrayAdapter<ActivityInfo> //程序自定义视图
public final class FloatingFolder extends StandOutWindow //只要继承 wei.mark.standout.StandOutWindow类 ,重写(Override)各种函数即可实现浮动窗体
- public class FloatingFoldersLauncher extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- StandOutWindow.closeAll(this, FloatingFolder.class);
- FloatingFolder.showFolders(this);
- finish();
- }
- }
实例项目StandOutExample:
- public class StandOutExampleActivity extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- StandOutWindow.closeAll(this, SimpleWindow.class);
- StandOutWindow.closeAll(this, MultiWindow.class);
- StandOutWindow.closeAll(this, WidgetsWindow.class);
- // show a MultiWindow, SimpleWindow
- StandOutWindow
- .show(this, SimpleWindow.class, StandOutWindow.DEFAULT_ID);
- StandOutWindow.show(this, MultiWindow.class, StandOutWindow.DEFAULT_ID);
- StandOutWindow.show(this, WidgetsWindow.class,
- StandOutWindow.DEFAULT_ID);
- // show a MostBasicWindow. It is commented out because it does not
- // support closing.
- /*
- * StandOutWindow.show(this, StandOutMostBasicWindow.class,
- * StandOutWindow.DEFAULT_ID);
- */
- finish();
- }
- }
- public class MostBasicWindow extends StandOutWindow {
- @Override
- public String getAppName() {
- return "MostBasicWindow";
- }
- @Override
- public int getAppIcon() {
- return android.R.drawable.btn_star;
- }
- @Override
- public void createAndAttachView(int id, FrameLayout frame) {
- TextView view = new TextView(this);
- view.setText("MostBasicWindow");
- view.setBackgroundColor(Color.CYAN);
- frame.addView(view);
- }
- @Override
- public StandOutLayoutParams getParams(int id, Window window) {
- return new StandOutLayoutParams(id, 200, 150, 100, 100);
- }
- }
其它的同上!
源码简单实用!