From 3c6fd7d9b28e004bb91063829b089a7d78572590 Mon Sep 17 00:00:00 2001 From: Sergey Chuvashev Date: Mon, 8 Sep 2014 23:38:38 +0400 Subject: [PATCH] [library] added DesignSpecActivity --- .../org/lucasr/dspec/DesignSpecActivity.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 library/src/main/java/org/lucasr/dspec/DesignSpecActivity.java diff --git a/library/src/main/java/org/lucasr/dspec/DesignSpecActivity.java b/library/src/main/java/org/lucasr/dspec/DesignSpecActivity.java new file mode 100644 index 0000000..8d9319c --- /dev/null +++ b/library/src/main/java/org/lucasr/dspec/DesignSpecActivity.java @@ -0,0 +1,46 @@ +package org.lucasr.dspec; + +import android.app.Activity; +import android.view.View; +import android.view.ViewGroup; +import android.widget.FrameLayout; + +/** + * Created with IntelliJ IDEA. + * User: Sergey Chuvashev + * Date: 08.09.14 + * Time: 23:30 + */ +public class DesignSpecActivity extends Activity { + + private DesignSpecFrameLayout mDesignSpecFrameLayout; + + @Override + public void onContentChanged() { + super.onContentChanged(); + + ViewGroup rootView = (ViewGroup) findViewById(android.R.id.content); + + DesignSpecFrameLayout designSpecFrameLayout = new DesignSpecFrameLayout(this); + + mDesignSpecFrameLayout = designSpecFrameLayout; + + int childCount = rootView.getChildCount(); + + View child; + for (int i = childCount - 1; i >= 0; i--) { + child = rootView.getChildAt(i); + rootView.removeView(child); + designSpecFrameLayout.addView(child); + } + + rootView.addView(designSpecFrameLayout, + new FrameLayout.LayoutParams( + FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); + } + + public DesignSpec getDesignSpec() { + return mDesignSpecFrameLayout.getDesignSpec(); + } + +}