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.lullabot.android.apps.iosched.ui.StarredActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_starred);
    getActivityHelper().setupActionBar(getTitle(), 0);

    mTabHost = (TabHost) findViewById(android.R.id.tabhost);
    mTabWidget = (TabWidget) findViewById(android.R.id.tabs);
    mTabHost.setup();/*from w  w w . ja  v  a  2 s . com*/
    // TODO: this is very inefficient and messy, clean it up
    FrameLayout fragmentContainer = new FrameLayout(this);
    fragmentContainer.setId(R.id.fragment_sessions);
    fragmentContainer.setLayoutParams(
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    ((ViewGroup) findViewById(android.R.id.tabcontent)).addView(fragmentContainer);

    final Intent intent = new Intent(Intent.ACTION_VIEW, Sessions.CONTENT_STARRED_URI);

    final FragmentManager fm = getSupportFragmentManager();
    mSessionsFragment = (SessionsFragment) fm.findFragmentByTag("sessions");
    if (mSessionsFragment == null) {
        mSessionsFragment = new SessionsFragment();
        mSessionsFragment.setArguments(intentToFragmentArguments(intent));
        fm.beginTransaction().add(R.id.fragment_sessions, mSessionsFragment, "sessions").commit();
    }

    // Sessions content comes from reused activity
    mTabHost.addTab(mTabHost.newTabSpec(TAG_SESSIONS).setIndicator(buildIndicator(R.string.starred_sessions))
            .setContent(R.id.fragment_sessions));
}

From source file:com.harlan.jxust.ui.view.bottombar.BottomBarBadge.java

protected BottomBarBadge(Context context, int position, final View tabToAddTo, // Rhyming accidentally! That's a Smoove Move!
        int backgroundColor) {
    super(context);

    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);

    setLayoutParams(params);//from  ww w  .jav a  2 s.co  m
    setGravity(Gravity.CENTER);
    MiscUtils.setTextAppearance(this, R.style.BB_BottomBarBadge_Text);

    int three = MiscUtils.dpToPixel(context, 3);
    ShapeDrawable backgroundCircle = BadgeCircle.make(three * 3, backgroundColor);
    setPadding(three, three, three, three);
    setBackgroundCompat(backgroundCircle);

    FrameLayout container = new FrameLayout(context);
    container.setLayoutParams(params);

    ViewGroup parent = (ViewGroup) tabToAddTo.getParent();
    parent.removeView(tabToAddTo);
    container.addView(tabToAddTo);
    container.addView(this);
    parent.addView(container, position);

    container.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @SuppressWarnings("deprecation")
        @Override
        public void onGlobalLayout() {
            adjustPositionAndSize(tabToAddTo);
        }
    });
}

From source file:com.community.yuequ.bottombar.BottomBarBadge.java

private void wrapTabAndBadgeInSameContainer(final BottomBarTab tab) {
    ViewGroup tabContainer = (ViewGroup) tab.getParent();
    tabContainer.removeView(tab);/* w  w  w.j  a  v  a2s. c  om*/

    final FrameLayout badgeContainer = new FrameLayout(getContext());
    badgeContainer.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    badgeContainer.addView(tab);
    badgeContainer.addView(this);

    tabContainer.addView(badgeContainer, tab.getIndexInTabContainer());

    badgeContainer.getViewTreeObserver()
            .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @SuppressWarnings("deprecation")
                @Override
                public void onGlobalLayout() {
                    badgeContainer.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                    adjustPositionAndSize(tab);
                }
            });
}

From source file:com.geomarket.ui_logic.SuperAwesomeCardFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    FrameLayout fl = new FrameLayout(getActivity());
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    fl.setLayoutParams(params);

    switch (position) {

    case 0:/*from w  w  w .  j a v  a2s. c o m*/
        View offerView = inflater.inflate(R.layout.activity_fragment_offer, null);
        fl.addView(offerView);
        Fragment offerFragment = new FragmentOffer();
        getFragmentManager().beginTransaction().replace(R.id.tab_offerview, offerFragment).commit();
        break;
    case 1:
        View favView = inflater.inflate(R.layout.activity_fragment_fav, null);
        fl.addView(favView);
        Fragment favFragment = new FragmentFav();
        getFragmentManager().beginTransaction().replace(R.id.tab_favview, favFragment).commit();
        break;
    case 2:
        View GoogleMapView = inflater.inflate(R.layout.activity_fragmentgooglemap, null);
        fl.addView(GoogleMapView);
        Fragment googlefragment = new Fragmentgooglemap();
        getFragmentManager().beginTransaction().replace(R.id.tab_googlemap, googlefragment).commit();
        break;
    }

    return fl;
}

From source file:de.tobiasbielefeld.solitaire.ui.manual.ManualGames.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_manual_games, container, false);

    ((Manual) getActivity()).setGamePageShown(false);

    layout1 = (ScrollView) view.findViewById(R.id.manual_games_layout_selection);
    scrollView = (ScrollView) view.findViewById(R.id.manual_games_scrollView);
    textName = (TextView) view.findViewById(R.id.manual_games_name);
    textStructure = (TextView) view.findViewById(R.id.manual_games_structure);
    textObjective = (TextView) view.findViewById(R.id.manual_games_objective);
    textRules = (TextView) view.findViewById(R.id.manual_games_rules);
    textScoring = (TextView) view.findViewById(R.id.manual_games_scoring);
    textBonus = (TextView) view.findViewById(R.id.manual_games_bonus);

    layout1.setVisibility(View.VISIBLE);
    scrollView.setVisibility(View.GONE);

    //if the manual is called from the in game menu, show the corresponding game rule page
    if (getArguments() != null && getArguments().containsKey(GAME)) {
        loadGameText(getArguments().getString(GAME));
    }//  w w  w . ja va  2 s .  c o m

    //load the table
    String[] gameList = lg.getDefaultGameNameList(getResources());
    TableRow row = new TableRow(getContext());
    TableLayout tableLayout = (TableLayout) view.findViewById(R.id.manual_games_container);
    TypedValue typedValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, typedValue, true);

    TableRow.LayoutParams params = new TableRow.LayoutParams(0, TableRow.LayoutParams.WRAP_CONTENT);
    params.weight = 1;

    //add each button
    for (int i = 0; i < lg.getGameCount(); i++) {
        Button entry = new Button(getContext());

        if (i % COLUMNS == 0) {
            row = new TableRow(getContext());
            tableLayout.addView(row);
        }

        entry.setBackgroundResource(typedValue.resourceId);
        entry.setEllipsize(TextUtils.TruncateAt.END);
        entry.setMaxLines(1);
        entry.setLayoutParams(params);
        entry.setText(gameList[i]);
        entry.setOnClickListener(this);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            entry.setAllCaps(false);
        }

        row.addView(entry);
    }

    //add some dummies to the last row, if necessary
    while (row.getChildCount() < COLUMNS) {
        FrameLayout dummy = new FrameLayout(getContext());
        dummy.setLayoutParams(params);
        row.addView(dummy);
    }

    return view;
}

From source file:fragment.MusicFragment.java

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

    FrameLayout fl = new FrameLayout(getActivity());
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    fl.setLayoutParams(params);

    switch (position) {
    case 0:/*from  ww  w. ja  va 2 s.  c o m*/
        View recorderView = inflater.inflate(R.layout.tab_recorder, null);
        fl.addView(recorderView);
        Fragment recorderFragment = new RecorderFragment();
        getFragmentManager().beginTransaction().replace(R.id.tab_recorder, recorderFragment).commit();
        break;
    case 1:
        View drumView = inflater.inflate(R.layout.tab_drum, null);
        fl.addView(drumView);
        Fragment drumFragment = new DrumFragment();
        getFragmentManager().beginTransaction().replace(R.id.tab_drum, drumFragment).commit();
        break;
    case 2:
        View saxophoneView = inflater.inflate(R.layout.tab_saxophone, null);
        fl.addView(saxophoneView);
        Fragment saxophoneFragment = new SaxophoneFragment();
        getFragmentManager().beginTransaction().replace(R.id.tab_saxophone, saxophoneFragment).commit();
        break;
    case 3:
        View handBellView = inflater.inflate(R.layout.tab_handbell, null);
        fl.addView(handBellView);
        Fragment handBellFragment = new HandBellFragment();
        getFragmentManager().beginTransaction().replace(R.id.tab_handbell, handBellFragment).commit();
        break;
    case 4:
        View harpView = inflater.inflate(R.layout.tab_harp, null);
        fl.addView(harpView);
        Fragment harpFragment = new HarpFragment();
        getFragmentManager().beginTransaction().replace(R.id.tab_harp, harpFragment).commit();
        break;
    }
    return fl;
}

From source file:tw.idv.gasolin.pycontw2012.ui.SearchActivity.java

/**
 * Build and add "sessions" tab./*from w w  w . j  a va  2  s .co  m*/
 */
private void setupSessionsTab() {
    // TODO: this is very inefficient and messy, clean it up
    FrameLayout fragmentContainer = new FrameLayout(this);
    fragmentContainer.setId(R.id.fragment_sessions);
    fragmentContainer.setLayoutParams(
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    ((ViewGroup) findViewById(android.R.id.tabcontent)).addView(fragmentContainer);

    final FragmentManager fm = getSupportFragmentManager();
    mSessionsFragment = (SessionsFragment) fm.findFragmentByTag("sessions");
    if (mSessionsFragment == null) {
        mSessionsFragment = new SessionsFragment();
        mSessionsFragment.setArguments(getSessionsFragmentArguments());
        fm.beginTransaction().add(R.id.fragment_sessions, mSessionsFragment, "sessions").commit();
    }

    // Sessions content comes from reused activity
    mTabHost.addTab(mTabHost.newTabSpec(TAG_SESSIONS).setIndicator(buildIndicator(R.string.starred_sessions))
            .setContent(R.id.fragment_sessions));
}

From source file:org.cocos2dx.lib.Cocos2dxFragmentActivity.java

public void init() {

    View v = null;/*  www  .j a v a  2  s  .  co  m*/
    if (useCustomContentView) {
        // Cocos2dxGLSurfaceView
        this.mGLSurfaceView = this.onCreateView();

        // Switch to supported OpenGL (ARGB888) mode on emulator
        if (isAndroidEmulator())
            this.mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
        this.mGLSurfaceView.setCocos2dxRenderer(new Cocos2dxRenderer());

        v = initLayout(this.mGLSurfaceView);
    }

    if (v != null) {
        setContentView(v);
        return;
    }

    // FrameLayout
    ViewGroup.LayoutParams framelayout_params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT);
    FrameLayout framelayout = new FrameLayout(this);
    framelayout.setLayoutParams(framelayout_params);

    // Cocos2dxEditText layout
    ViewGroup.LayoutParams edittext_layout_params = new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    Cocos2dxEditText edittext = new Cocos2dxEditText(this);
    edittext.setLayoutParams(edittext_layout_params);

    // ...add to FrameLayout
    framelayout.addView(edittext);

    // Cocos2dxGLSurfaceView
    this.mGLSurfaceView = this.onCreateView();

    // ...add to FrameLayout
    framelayout.addView(this.mGLSurfaceView);

    // Switch to supported OpenGL (ARGB888) mode on emulator
    if (isAndroidEmulator())
        this.mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);

    this.mGLSurfaceView.setCocos2dxRenderer(new Cocos2dxRenderer());
    this.mGLSurfaceView.setCocos2dxEditText(edittext);

    // Set framelayout as the content view
    setContentView(framelayout);
}

From source file:com.goliathonline.android.kegbot.ui.StarredActivity.java

/**
 * Build and add "vendors" tab.//  w w  w .j  ava  2 s.  co m
 */
private void setupKegsTab() {
    // TODO: this is very inefficient and messy, clean it up
    FrameLayout fragmentContainer = new FrameLayout(this);
    fragmentContainer.setId(R.id.fragment_kegs);
    fragmentContainer.setLayoutParams(
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    ((ViewGroup) findViewById(android.R.id.tabcontent)).addView(fragmentContainer);

    final Intent intent = new Intent(Intent.ACTION_VIEW, Kegs.CONTENT_STARRED_URI);

    final FragmentManager fm = getSupportFragmentManager();

    mKegsFragment = (KegsFragment) fm.findFragmentByTag("kegs");
    if (mKegsFragment == null) {
        mKegsFragment = new KegsFragment();
        mKegsFragment.setArguments(intentToFragmentArguments(intent));
        fm.beginTransaction().add(R.id.fragment_kegs, mKegsFragment, "kegs").commit();
    }

    // Vendors content comes from reused activity
    mTabHost.addTab(mTabHost.newTabSpec(TAG_KEGS).setIndicator(buildIndicator(R.string.starred_kegs))
            .setContent(R.id.fragment_kegs));
}

From source file:com.goliathonline.android.kegbot.ui.StarredActivity.java

/**
 * Build and add "sessions" tab.//from  w  w  w . j  a  va2  s  . co  m
 */
private void setupSessionsTab() {
    // TODO: this is very inefficient and messy, clean it up
    FrameLayout fragmentContainer = new FrameLayout(this);
    fragmentContainer.setId(R.id.fragment_drinks);
    fragmentContainer.setLayoutParams(
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    ((ViewGroup) findViewById(android.R.id.tabcontent)).addView(fragmentContainer);

    final Intent intent = new Intent(Intent.ACTION_VIEW, Drinks.CONTENT_STARRED_URI);

    final FragmentManager fm = getSupportFragmentManager();
    mDrinksFragment = (DrinksFragment) fm.findFragmentByTag("drinks");
    if (mDrinksFragment == null) {
        mDrinksFragment = new DrinksFragment();
        mDrinksFragment.setArguments(intentToFragmentArguments(intent));
        fm.beginTransaction().add(R.id.fragment_drinks, mDrinksFragment, "drinks").commit();
    }

    // Sessions content comes from reused activity
    mTabHost.addTab(mTabHost.newTabSpec(TAG_DRINKS).setIndicator(buildIndicator(R.string.starred_drinks))
            .setContent(R.id.fragment_drinks));
}