Example usage for android.widget FrameLayout setLayoutParams

List of usage examples for android.widget FrameLayout setLayoutParams

Introduction

In this page you can find the example usage for android.widget FrameLayout setLayoutParams.

Prototype

public void setLayoutParams(ViewGroup.LayoutParams params) 

Source Link

Document

Set the layout parameters associated with this view.

Usage

From source file:com.github.jvanhie.discogsscrobbler.ReleaseListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    //check if the user wants to enable discogs support, if not, stop here
    if (!PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean("enable_discogs", true)) {
        View emptyView = inflater.inflate(R.layout.fragment_empty, container, false);
        ((TextView) emptyView.findViewById(R.id.empty_heading)).setText("Discogs not enabled");
        ((TextView) emptyView.findViewById(R.id.empty_text)).setText(
                "Cannot display your collection without Discogs support, enable Discogs in the settings menu if you'd like to use this feature");
        mCallbacks.onAdapterSet();//  w ww  .  j  a  va  2  s .  c  om
        return emptyView;
    }

    String layout = PreferenceManager.getDefaultSharedPreferences(getActivity()).getString("collection_view",
            "");
    if (layout.equals("list")) {
        //setup list view
        mList = new ListView(getActivity());
        mList.setId(android.R.id.list);
    } else {
        mList = new GridView(getActivity());
        mList.setId(android.R.id.list);
        mGrid = true;
    }

    mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            onListItemClick(view, i, l);
        }
    });

    mList.setFastScrollEnabled(true);

    //create superframe for adding list and empty view
    FrameLayout superFrame = new FrameLayout(getActivity());
    FrameLayout.LayoutParams layoutparams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    superFrame.setLayoutParams(layoutparams);
    View emptyView = inflater.inflate(R.layout.fragment_empty, container, false);
    mEmptyHeading = ((TextView) emptyView.findViewById(R.id.empty_heading));
    mEmptyHeading.setText("Empty collection");
    mEmptyText = ((TextView) emptyView.findViewById(R.id.empty_text));
    mEmptyText.setText(
            "Your collection appears to be empty, if this isn't an error, start by adding some releases via the search function or online");

    /*initialize list with local discogs collection*/
    if (mDiscogs == null)
        mDiscogs = Discogs.getInstance(getActivity());

    loadList();

    if (PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean("collection_auto_refresh",
            true)) {
        //do a background call to update the discogs collection if necessary
        checkOnlineCollection();
    }

    superFrame.addView(emptyView);
    mList.setEmptyView(emptyView);
    superFrame.addView(mList);

    return superFrame;
}

From source file:com.arman.efficientqhalgoforch.SuperAwesomeCardFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    if (position == 2) {
        final View vv = inflater.inflate(R.layout.benchmark_lay, null);

        Button run = (Button) vv.findViewById(R.id.runAlgor);
        Button reset = (Button) vv.findViewById(R.id.cleardata);
        run.setOnClickListener(new View.OnClickListener() {
            @Override/*from w w w . java2s .  c om*/
            public void onClick(View v) {
                EditText thrd;
                EditText points;
                EditText canvasY;
                EditText canvasX;
                thrd = (EditText) vv.findViewById(R.id.numberTreadstxt);
                points = (EditText) vv.findViewById(R.id.numberpoints);
                canvasX = (EditText) vv.findViewById(R.id.canvasWidth);
                canvasY = (EditText) vv.findViewById(R.id.canvasHeight);
                int threads = Integer.valueOf(thrd.getText().toString());
                int ponts = Integer.valueOf(points.getText().toString());
                int canvY = Integer.valueOf(canvasY.getText().toString());
                int canvX = Integer.valueOf(canvasX.getText().toString());

                if (threads < 1)
                    threads = 1;
                if (ponts <= 2)
                    ponts = 3;
                if (threads > ponts)
                    threads = ponts - 1;
                if (threads > 25)
                    threads = 25;
                if (canvX + 100 < ponts)
                    canvX = canvX + 100;
                if (canvY + 100 < ponts)
                    canvY = canvY + 100;

                final Point2DCloud point2DCloud = new Point2DCloud(getActivity(), ponts /* points */,
                        Utils.WIDTH = canvY, Utils.HEIGHT = canvX, true);

                int animTime = 10;
                final int finalThreads = threads;
                final int finalPonts = ponts;
                QuickHull qh = new QuickHull(point2DCloud, threads, true, animTime, new DoneListener() {
                    @Override
                    public void jobDone(int id, float time) {
                        mResults.add(new DataHolder(finalThreads, time, finalPonts));
                        updateChart(mResults);

                    }
                });
                qh.run();
                algorithmIndex = 2;

            }
        });

        reset.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                for (DataHolder hld : mResults) {
                    mResults.remove(hld);
                }

                updateChart(mResults);

            }
        });
        doHardcore(vv, inflater);

        return vv;
    } else if (position == 3) {

        final View vv = inflater.inflate(R.layout.benchmark_lay, null);

        ((TextView) vv.findViewById(R.id.nametxt)).setText("             GrahamScan\n Multithreaded Benchmark");

        Button run = (Button) vv.findViewById(R.id.runAlgor);
        Button resetgr = (Button) vv.findViewById(R.id.cleardata);
        run.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EditText thrd;
                EditText points;
                EditText canvasY;
                EditText canvasX;
                thrd = (EditText) vv.findViewById(R.id.numberTreadstxt);
                points = (EditText) vv.findViewById(R.id.numberpoints);
                canvasX = (EditText) vv.findViewById(R.id.canvasWidth);
                canvasY = (EditText) vv.findViewById(R.id.canvasHeight);
                int threads = Integer.valueOf(thrd.getText().toString());
                int ponts = Integer.valueOf(points.getText().toString());
                int canvY = Integer.valueOf(canvasY.getText().toString());
                int canvX = Integer.valueOf(canvasX.getText().toString());

                if (threads < 1)
                    threads = 1;
                if (ponts <= 2)
                    ponts = 3;
                if (threads > ponts)
                    threads = ponts - 1;
                if (threads > 25)
                    threads = 25;
                if (canvX + 100 < ponts)
                    canvX = canvX + 100;
                if (canvY + 100 < ponts)
                    canvY = canvY + 100;

                final Point2DCloud point2DCloud = new Point2DCloud(getActivity(), ponts /* points */,
                        Utils.WIDTH = canvY, Utils.HEIGHT = canvX, true);

                int animTime = 10;
                final int finalThreads = threads;
                final int finalPonts = ponts;
                GrahamScanParallel gh = new GrahamScanParallel(point2DCloud, threads, true, animTime,
                        new DoneListener() {
                            @Override
                            public void jobDone(int id, float time) {
                                mGResults.add(new DataHolder(finalThreads, time, finalPonts));
                                updateChart(mGResults);

                            }
                        });
                gh.run();
                algorithmIndex = 3;

            }
        });

        resetgr.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                for (DataHolder hld : mGResults) {
                    mGResults.remove(hld);
                }
                updateChart(mGResults);
            }
        });
        doHardcore(vv, inflater);

        return vv;

    } else {

        if (position == 0) {

            LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

            FrameLayout fl = new FrameLayout(getActivity());
            fl.setLayoutParams(params);

            final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                    getResources().getDisplayMetrics());

            View v = (View) inflater.inflate(R.layout.intro, null);
            params.setMargins(margin, margin, margin, margin);
            v.setLayoutParams(params);
            v.setLayoutParams(params);
            //v.setBackgroundResource(R.drawable.background_card);

            fl.addView(v);
            //fl.addView(btn);
            return fl;
        } else if (position == 1) {
            LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

            FrameLayout fl = new FrameLayout(getActivity());
            fl.setLayoutParams(params);

            final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                    getResources().getDisplayMetrics());

            View v = (View) inflater.inflate(R.layout.algo, null);
            params.setMargins(margin, margin, margin, margin);
            v.setLayoutParams(params);
            v.setLayoutParams(params);
            //v.setBackgroundResource(R.drawable.background_card);

            fl.addView(v);

            return fl;
        }

    }
    return null;
}

From source file:jfabrix101.lib.fragmentActivity.AbstractFragmentActivityController.java

/**
 * Crea un layout verticale utilizzando il solo fragment di sinistra (la lista)
 *///from  w w  w  .jav  a2  s . com
@SuppressWarnings("all")
protected View makeLeftPortraitLayout(LayoutInflater inflater) {
    if (getLayoutResourceId() > 0) {
        View v = LayoutInflater.from(this).inflate(getLayoutResourceId(), null);
        View rightFragment = v.findViewById(getRightFragmentId());
        if (rightFragment != null) {
            rightFragment.setVisibility(View.GONE);
        }
        mVisualizationMode = VisualizationMode.PORTRAIT_ONLY_LEFT;
        return v;
    } else {
        LinearLayout layout = new LinearLayout(this);

        layout.setPadding(10, 10, 10, 10);
        layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        layout.setOrientation(LinearLayout.VERTICAL);

        FrameLayout leftFrame = new FrameLayout(this);
        leftFrame.setId(getLeftFragmentId());
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.FILL_PARENT);
        leftFrame.setLayoutParams(lp);

        layout.addView(leftFrame);
        mVisualizationMode = VisualizationMode.PORTRAIT_ONLY_LEFT;
        return layout;
    }
}

From source file:jfabrix101.lib.fragmentActivity.AbstractFragmentActivityController.java

/**
 * Crea un layout in landscape utilizzando due fragment di peso proporzionale
 * Per cambiare le dimensioni dei pesi effettuare l'override dei 
 * metodi <code>getLeftFragmentSize</code> e <code>getRightFragmentSize</code> 
 *//* ww w .  j  a  v  a2 s .c  om*/
@SuppressWarnings("all")
protected View makeLandscapeLayout(LayoutInflater inflater) {
    if (getLayoutResourceId() > 0) {
        View v = inflater.inflate(getLayoutResourceId(), null);
        mVisualizationMode = VisualizationMode.LANDSCAPE;
        return v;
    } else {
        LinearLayout layout = new LinearLayout(this);
        layout.setPadding(10, 10, 10, 10);
        layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        layout.setOrientation(LinearLayout.HORIZONTAL);

        FrameLayout leftFrame = new FrameLayout(this);
        leftFrame.setId(getLeftFragmentId());
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LayoutParams.FILL_PARENT,
                getLeftFragmentWeigth());
        leftFrame.setLayoutParams(lp);

        FrameLayout rightFrame = new FrameLayout(this);
        rightFrame.setId(getRightFragmentId());
        lp = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, getRightFragmentWeigth());
        rightFrame.setLayoutParams(lp);

        layout.addView(leftFrame);
        layout.addView(rightFrame);
        mVisualizationMode = VisualizationMode.LANDSCAPE;
        return layout;
    }

}

From source file:jfabrix101.lib.fragmentActivity.AbstractFragmentActivityController.java

/**
 * Crea un layout verticale utilizzando il solo fragment di destra (il dettaglio)
 *///  ww w. j ava 2s  . c  o m
@SuppressWarnings("all")
protected View makeRightPortraitLayout(LayoutInflater inflater) {
    if (getLayoutResourceId() > 0) {
        View v = LayoutInflater.from(this).inflate(getLayoutResourceId(), null);
        View leftFragment = v.findViewById(getLeftFragmentId());
        if (leftFragment != null) {
            leftFragment.setVisibility(View.GONE);
        }
        mVisualizationMode = VisualizationMode.PORTRAIT_ONLY_RIGHT;
        //         getActionBar().setDisplayHomeAsUpEnabled(true); 
        return v;
    } else {
        LinearLayout layout = new LinearLayout(this);

        layout.setPadding(10, 10, 10, 10);
        layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        layout.setOrientation(LinearLayout.VERTICAL);

        FrameLayout rightFrame = new FrameLayout(this);
        rightFrame.setId(getRightFragmentId());
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.FILL_PARENT);
        rightFrame.setLayoutParams(lp);

        layout.addView(rightFrame);
        mVisualizationMode = VisualizationMode.PORTRAIT_ONLY_RIGHT;
        //         getActionBar().setDisplayHomeAsUpEnabled(true); 
        return layout;
    }
}

From source file:com.esri.android.ecologicalmarineunitexplorer.MainActivity.java

/**
 * Show the view with the water column profiles
 * @param point - Point representing clicked geo location
 *///from  w  w w.  ja va 2 s  .c  o m
private void showWaterColumnProfile(final Point point) {
    // Remove water column, summary, text and button
    mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
    // hideMapView();

    setUpWaterProfileToolbar();

    final FrameLayout layout = (FrameLayout) findViewById(R.id.chartContainer);
    if (layout != null) {
        layout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        layout.requestLayout();
    }

    final WaterProfileFragment waterProfileFragment = WaterProfileFragment.newInstance();
    new WaterProfilePresenter(point, waterProfileFragment, mDataManager);

    // Add the chart view to the column container
    final FragmentManager fm = getSupportFragmentManager();
    final FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    final Fragment f = fm.findFragmentById(R.id.chartContainer);
    if (f == null) {
        transaction.addToBackStack(getString(R.string.fragment_detail_chart));
    }
    transaction.replace(R.id.chartContainer, waterProfileFragment);
    transaction.commit();

    // Hide the FAB
    mFab.setVisibility(View.INVISIBLE);

    mInMapState = false;
}

From source file:com.esri.android.ecologicalmarineunitexplorer.MainActivity.java

/**
 * Show the candlestick charts for a specific EMU layer
 * @param emuName - int representing an EMU layer name
 *//*from   w w  w  .  j  av a 2s  .  c  om*/
private void showSummaryDetail(final int emuName) {
    // Hide the bottom sheet containing the summary view
    mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);

    // Expand the layout for the charts
    final FrameLayout layout = (FrameLayout) findViewById(R.id.chartContainer);
    if (layout != null) {
        layout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        layout.requestLayout();
    }

    if (mSummaryChartFragment == null) {
        mSummaryChartFragment = SummaryChartFragment.newInstance();
        mSummaryChartPresenter = new SummaryChartPresenter(emuName, mSummaryChartFragment, mDataManager);
    } else {
        mSummaryChartPresenter.setEmuName(emuName);
    }

    // Add the chart view to the column container
    final FragmentManager fm = getSupportFragmentManager();
    final FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    final Fragment f = fm.findFragmentById(R.id.chartContainer);
    if (f == null) {
        transaction.addToBackStack(getString(R.string.fragment_detail_chart));
    }
    transaction.replace(R.id.chartContainer, mSummaryChartFragment);
    transaction.commit();

    // Hide the FAB
    mFab.setVisibility(View.INVISIBLE);
    mInMapState = false;

    setUpChartSummaryToolbar(emuName);
}

From source file:com.taobao.weex.extend.module.actionsheet.WXActionSheet.java

private View createRoot() {
    FrameLayout parent = new FrameLayout(getActivity());
    parent.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    backgroundLayer = new View(getActivity());
    backgroundLayer.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    backgroundLayer.setBackgroundColor(Color.argb(136, 0, 0, 0));
    backgroundLayer.setOnClickListener(new View.OnClickListener() {
        @Override//from   www . ja v a  2  s . c  o  m
        public void onClick(View v) {
            dismiss();
            if (actionListener != null) {
                actionListener.onCancel();
            }
        }
    });

    sheetContainer = new LinearLayout(getActivity());
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.BOTTOM;
    sheetContainer.setLayoutParams(params);
    sheetContainer.setOrientation(LinearLayout.VERTICAL);
    sheetContainer.setPadding(dp2px(8), dp2px(8), dp2px(8), dp2px(8));

    parent.setPadding(0, 0, 0, getNavBarHeight(getActivity()));
    parent.addView(backgroundLayer);
    parent.addView(sheetContainer);
    return parent;
}

From source file:com.putaotown.views.PagerSlidingTabStrip.java

private void addIconTab(final int position, int resId) {
    boolean isMessage = false; //??
    if (resId == R.drawable.iconfont_message || resId == R.drawable.iconfont_message_press)
        isMessage = true;//from w  w  w .j  av a2 s . c  om

    ImageButton tab = new ImageButton(getContext());
    //      LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1);
    LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(
            (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabWidth,
                    getResources().getDisplayMetrics()),
            (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabWidth,
                    getResources().getDisplayMetrics()));
    int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10,
            getResources().getDisplayMetrics());

    if (isMessage) {
        FrameLayout.LayoutParams paramx = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
                (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabWidth,
                        getResources().getDisplayMetrics()));
        FrameLayout flayout = new FrameLayout(this.getContext());
        param.gravity = Gravity.RIGHT;
        flayout.setLayoutParams(param);
        flayout.setPadding(padding, padding, padding, padding);
        View view = inflate(this.getContext(), R.layout.actionbar_mess_view, null);
        this.messRedPos = view.findViewById(R.id.actionbar_mess_redpos);
        this.messImage = (ImageView) view.findViewById(R.id.actionbar_mess_icon);
        flayout.addView(view);
        flayout.setTag("mess"); //??
        addTab(position, flayout);
    } else {
        tab.setLayoutParams(param);
        tab.setPadding(padding, padding, padding, padding);
        tab.setImageResource(resId);
        tab.setScaleType(ScaleType.CENTER_INSIDE);
        tab.setAdjustViewBounds(true);
        addTab(position, tab);
    }

}