Example usage for android.widget FrameLayout addView

List of usage examples for android.widget FrameLayout addView

Introduction

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

Prototype

public void addView(View child) 

Source Link

Document

Adds a child view.

Usage

From source file:com.collcloud.frame.viewpager.main.Fragment2.java

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

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

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);/* w  ww . j av  a 2 s  .  co  m*/

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

    TextView v = new TextView(getActivity());
    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    v.setBackgroundResource(R.drawable.tab_pagertab_background_card);
    v.setText("fragment2 CARD is " + (position + 1));

    fl.addView(v);
    return fl;
}

From source file:com.example.hudpassthrough.BluetoothChat.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (D)/*w  w w  .  j a v  a 2s.c  om*/
        Log.e(TAG, "+++ ON CREATE +++");

    // Set up the window layout
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.main);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);

    // Set up the custom title
    mTitle = (TextView) findViewById(R.id.title_left_text);
    mTitle.setText(R.string.app_name);
    mTitle = (TextView) findViewById(R.id.title_right_text);

    // Get local Bluetooth adapter
    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

    // If the adapter is null, then Bluetooth is not supported
    if (mBluetoothAdapter == null) {
        Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
        finish();
        return;
    }

    mCamera = Camera.open();
    if (mCamera == null)
        Log.e("Camera", "mCamera is null!");

    //mCamera.enableShutterSound(false); //Questionable Legality!

    CamPreview camPreview = new CamPreview(this, mCamera);
    camPreview.setSurfaceTextureListener(camPreview);
    FrameLayout preview = (FrameLayout) findViewById(R.id.cameraView);
    preview.addView(camPreview);
    CamCallback camCallback = new CamCallback();
    mCamera.setPreviewCallback(camCallback);

    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitAll().build());

    people = new PeopleDB();
}

From source file:com.vista.negocio.SuperAwesomeCardFragment.java

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

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

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);//from   w ww .jav  a 2s. c o  m

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

    TextView v = new TextView(getActivity());
    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    v.setBackgroundResource(R.drawable.background_card);
    v.setText("Aqui poner una listta de item:    Nro " + (position + 1));

    fl.addView(v);
    return fl;
}

From source file:com.visk.xperiatuner.cpucontrol.CpuControlFragment.java

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

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

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);/*from   w  w  w . ja  v a  2s.  c  om*/

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

    TextView v = new TextView(getActivity());
    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    v.setBackgroundResource(R.drawable.background_card);
    //      v.setText("CARD " + (position + 1));
    v.setText("CARD ");

    fl.addView(v);
    return fl;
}

From source file:com.osama.cryptofm.filemanager.ui.FilemanagerTabs.java

@Override
public void showNoFilesFragment() {
    Log.d("google", "showNoFilesFragment: no files show");
    isEmptyFolder = true;//from   w  w  w .  j  a  va  2  s  .  c  o  m
    FrameLayout layout = (FrameLayout) findViewById(R.id.no_files_frame_fragment);
    View view = getLayoutInflater().inflate(R.layout.no_files_layout, null);
    layout.addView(view);
    mCurrentFragment.setmIsEmptyFolder(true);
}

From source file:com.commnsense.proximity.fragments.SuperAwesomeCardFragment.java

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

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

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);/* w ww  . jav a2s. c  o m*/
    fl.setBackgroundColor(0xffa9a9a9);

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

    TextView v = new TextView(getActivity());
    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    v.setBackgroundResource(R.drawable.background_card);
    v.setText("CARD " + (position + 1));

    fl.addView(v);
    return fl;
}

From source file:it.geosolutions.geocollect.android.core.form.FormPageFragment.java

/**
 * Creates the page content cycling the page fields
 *//*w ww .  ja v a 2 s . com*/
private void buildForm() {

    if (BuildConfig.DEBUG) {
        Log.d(TAG, "buildForm()");
    }

    // if the view hierarchy was already build, skip this
    if (mDone) {
        return;
    }

    FormBuilder.buildForm(getActivity(), this.mFormView, page.fields, mission);//TODO page is not enough, some data should be accessible like constants and data

    // It is safe to initialize field here because buildForm is a callback of the onActivityCreated();
    PersistenceUtils.loadPageData(page, mFormView, mission, getActivity(), true);

    // TODO: add a timer and start an animation for the tutorial
    if (page.attributes != null && page.attributes.containsKey("tutorial")) {
        if (page.attributes.get("tutorial") != null && page.attributes.get("tutorial") instanceof Boolean
                && (Boolean) page.attributes.get("tutorial")) {

            Log.v(TAG, "Showing tutorial");

            // create new Layout
            FrameLayout overlayFramelayout = new FrameLayout(getSherlockActivity());

            View view = getSherlockActivity().getLayoutInflater().inflate(R.layout.swipe_overlay,
                    overlayFramelayout, false);

            overlayFramelayout.addView(view);

            // Viewpager layoutparams
            LayoutParams layoutParams = new LayoutParams();
            layoutParams.gravity = Gravity.BOTTOM;
            //getSherlockActivity().addContentView(overlayFramelayout, layoutParams);
            this.mFormView.addView(overlayFramelayout, layoutParams);

        }
    }
    // the view hierarchy is now complete
    mDone = true;

    // TODO: merge this code block with the previous "tutorial"
    if (visibleToUser && page.attributes != null && page.attributes.containsKey("message")) {
        Toast.makeText(getSherlockActivity(), (String) page.attributes.get("message"), Toast.LENGTH_LONG)
                .show();
    }

}

From source file:com.danielhan.neteasenews.activity.SuperAwesomeCardFragment.java

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

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

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setBackgroundResource(R.color.divider);
    fl.setLayoutParams(params);//from w w  w  .  j  a v a2 s. c  om

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

    TextView v = new TextView(getActivity());
    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    //      v.setBackgroundResource(R.drawable.background_card);
    v.setText("CARD " + (position + 1));

    fl.addView(v);
    return fl;
}

From source file:com.woodblockwithoutco.quickcontroldock.ui.factory.ServiceViewFactory.java

@SuppressWarnings("deprecation")
public View getServiceView() {

    boolean sameLayout = GeneralResolver.isSameLayoutForLandscape(mContext);
    int inflateId = 0;
    if (ScreenUtils.getScreenOrientation(mContext) == Configuration.ORIENTATION_PORTRAIT || sameLayout) {
        inflateId = R.layout.panel_layout;
    } else {//from  ww  w  .j  av a2 s . c o  m
        inflateId = R.layout.panel_layout_land;
    }

    View view = LayoutInflater.from(mContext).inflate(inflateId, null, false);

    final DragViewGroup dragView = (DragViewGroup) view.findViewById(R.id.panel_drag_handler);
    dragView.setBackgroundDrawable(ColorsResolver.getBackgroundDrawable(mContext));

    if (ConstantHolder.getIsDebug()) {
        initTestVersionText(dragView);
    }

    ViewGroup viewToHide;
    if (ScreenUtils.getScreenOrientation(mContext) == Configuration.ORIENTATION_PORTRAIT || sameLayout) {
        LinearLayout panelsContainer = (LinearLayout) dragView.findViewById(R.id.panels_container);
        viewToHide = panelsContainer;
        if (ScreenUtils.getScreenOrientation(mContext) == Configuration.ORIENTATION_PORTRAIT) {
            panelsContainer.setTranslationY(GeneralResolver.getPanelsOffset(mContext));
        }

        List<String> panelsOrder = PanelsOrderResolver.getPanelsOrder(mContext);
        if (ShortcutsResolver.isShortcutsEnabled(mContext)) {
            ShortcutsViewFactory svFactory = new ShortcutsViewFactory(mContext);
            int id = getContainerIdForPanelType(panelsOrder, PanelType.SHORTCUTS.name());
            FrameLayout section = (FrameLayout) view.findViewById(id);
            adjustPanelMargins(section);
            section.addView(svFactory.getShortcutsSectionView());
        }

        if (MusicResolver.isMusicPanelEnabled(mContext)) {
            MusicViewFactory mvFactory = new MusicViewFactory(mContext);
            int id = getContainerIdForPanelType(panelsOrder, PanelType.MUSIC.name());
            FrameLayout section = (FrameLayout) view.findViewById(id);
            adjustPanelMargins(section);
            section.addView(mvFactory.getMusicView());
        }

        if (TogglesResolver.isTogglesEnabled(mContext)) {
            TogglesViewFactory tvFactory = new TogglesViewFactory(mContext);
            int id = getContainerIdForPanelType(panelsOrder, PanelType.TOGGLES.name());
            FrameLayout section = (FrameLayout) view.findViewById(id);
            adjustPanelMargins(section);
            section.addView(tvFactory.getTogglesSectionView());
        }

        if (InfoResolver.isInfoPanelEnabled(mContext)) {
            InfoViewFactory ivFactory = new InfoViewFactory(mContext);
            int id = getContainerIdForPanelType(panelsOrder, PanelType.INFO.name());
            FrameLayout section = (FrameLayout) view.findViewById(id);
            adjustPanelMargins(section);
            section.addView(ivFactory.getInfoView());
        }

        if (NotificationsResolver.isNotificationsEnabled(mContext)) {
            final ImageView fakeNotificationsButton = (ImageView) dragView
                    .findViewById(R.id.notifications_button_fake);
            PressImageView notificationsButton = (PressImageView) dragView
                    .findViewById(R.id.notifications_button);
            fakeNotificationsButton.setVisibility(View.VISIBLE);
            notificationsButton.setVisibility(View.VISIBLE);
            fakeNotificationsButton.setImageResource(R.drawable.ic_notification_switch);
            fakeNotificationsButton.setColorFilter(ColorsResolver.getActiveColor(mContext));
            final float SCALE = 1.5f;
            fakeNotificationsButton.setScaleX(SCALE);
            fakeNotificationsButton.setScaleY(SCALE);
            notificationsButton.setOnPressedStateChangeListener(new OnPressedStateChangeListener() {
                private final int BG_COLOR = ColorsResolver.getPressedColor(mContext);

                @Override
                public void onPressedStateChange(ImageView v, boolean pressed) {
                    if (pressed) {
                        fakeNotificationsButton.setBackgroundColor(BG_COLOR);
                    } else {
                        fakeNotificationsButton.setBackgroundColor(0x00000000);
                    }
                }
            });

            NotificationViewFactory nvFactory = new NotificationViewFactory(mContext);
            ViewGroup notificationsView = nvFactory.getNotificationsView();
            notificationsView.setAlpha(0.0f);
            notificationsView.setVisibility(View.INVISIBLE);
            FrameLayout notificationsContainer = (FrameLayout) dragView
                    .findViewById(R.id.notifications_section);
            notificationsContainer.addView(notificationsView);
            notificationsButton
                    .setOnClickListener(new NotificationButtonClickListener(viewToHide, notificationsView));
        }

    } else {

        ViewPager pager = (ViewPager) view.findViewById(R.id.landscape_pager);
        viewToHide = pager;
        List<View> views = new ArrayList<View>();

        if (NotificationsResolver.isNotificationsEnabled(mContext)) {
            NotificationViewFactory nvFactory = new NotificationViewFactory(mContext);
            ViewGroup notificationsView = nvFactory.getNotificationsView();
            views.add(notificationsView);
        }

        List<String> panelsOrder = PanelsOrderResolver.getPanelsOrder(mContext);
        for (String t : panelsOrder) {
            PanelType type = PanelType.valueOf(t);
            View v = null;
            FrameLayout container = (FrameLayout) LayoutInflater.from(mContext)
                    .inflate(R.layout.panel_section_land, null, false);
            switch (type) {
            case INFO:
                //     
                if (InfoResolver.isInfoPanelEnabled(mContext)) {
                    InfoViewFactory ivFactory = new InfoViewFactory(mContext);
                    FrameLayout fourthSection = (FrameLayout) view.findViewById(R.id.fourth_section);
                    fourthSection.addView(ivFactory.getInfoView());
                }
                break;
            case MUSIC:
                if (MusicResolver.isMusicPanelEnabled(mContext)) {
                    MusicViewFactory mvFactory = new MusicViewFactory(mContext);
                    v = mvFactory.getMusicView();
                }
                break;
            case SHORTCUTS:
                if (ShortcutsResolver.isShortcutsEnabled(mContext)) {
                    ShortcutsViewFactory svFactory = new ShortcutsViewFactory(mContext);
                    v = svFactory.getShortcutsSectionView();
                }
                break;
            case TOGGLES:
                if (TogglesResolver.isTogglesEnabled(mContext)) {
                    TogglesViewFactory tvFactory = new TogglesViewFactory(mContext);
                    v = tvFactory.getTogglesSectionView();
                }
                break;
            }

            if (v != null) {
                views.add(v);
                container.addView(v);
            }
        }

        LandscapePanelsAdapter adapter = new LandscapePanelsAdapter(views);
        pager.setAdapter(adapter);
        pager.setOverScrollMode(View.OVER_SCROLL_NEVER);
        pager.setOffscreenPageLimit(VIEW_PAGER_OFFSCREEN_PAGES_COUNT);
        pager.setPageMargin(mContext.getResources().getDimensionPixelSize(R.dimen.pager_margin));
    }

    return view;
}

From source file:com.raffaele.squarecash4glass.CVVConfirmActivity.java

/**
 * Recommended "safe" way to open the camera.
 * //w  w w.j  a  v  a 2 s  .  c  o  m
 * @param view
 * @return
 */
private boolean safeCameraOpenInView(View view) {
    boolean qOpened = false;
    releaseCameraAndPreview();
    mCamera = getCameraInstance();
    qOpened = (mCamera != null);

    if (qOpened == true) {
        mPreview = new CameraPreview(getBaseContext(), mCamera, view);
        FrameLayout preview = (FrameLayout) view.findViewById(R.id.camera_preview);
        preview.addView(mPreview);
        mPreview.startCameraPreview();
        Log.i(TAG, "camera parameters:" + mCamera.getParameters());
        Log.i(TAG, "camera current size:"
                + ToStringBuilder.reflectionToString(mCamera.getParameters().getPictureSize()));
        Log.i(TAG,
                "camera supported sizes:" + ToStringBuilder.reflectionToString(
                        mCamera.getParameters().getSupportedPictureSizes().toArray(),
                        new RecursiveToStringStyle()));
        cameraAvailable = true;
    }
    Log.i(TAG, "safeCameraOpenInView completed.");
    return qOpened;
}