Example usage for android.view ViewGroup.LayoutParams ViewGroup.LayoutParams

List of usage examples for android.view ViewGroup.LayoutParams ViewGroup.LayoutParams

Introduction

In this page you can find the example usage for android.view ViewGroup.LayoutParams ViewGroup.LayoutParams.

Prototype

public LayoutParams(int width, int height) 

Source Link

Document

Creates a new set of layout parameters with the specified width and height.

Usage

From source file:org.geometerplus.android.fbreader.bookmark.EditBookmarkActivity.java

@Override
public void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.edit_bookmark);

    myBookmark = FBReaderIntents.getBookmarkExtra(getIntent());
    if (myBookmark == null) {
        finish();/*w  ww .  j a v a 2s.co  m*/
        return;
    }

    final DisplayMetrics dm = getResources().getDisplayMetrics();
    final int width = Math.min((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 500, dm),
            dm.widthPixels * 9 / 10);
    final int height = Math.min((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 350, dm),
            dm.heightPixels * 9 / 10);

    final TabHost tabHost = (TabHost) findViewById(R.id.edit_bookmark_tabhost);
    tabHost.setLayoutParams(new FrameLayout.LayoutParams(new ViewGroup.LayoutParams(width, height)));
    tabHost.setup();

    addTab(tabHost, "text", R.id.edit_bookmark_content_text);
    addTab(tabHost, "style", R.id.edit_bookmark_content_style);
    addTab(tabHost, "delete", R.id.edit_bookmark_content_delete);

    final ZLStringOption currentTabOption = new ZLStringOption("LookNFeel", "EditBookmark", "text");
    tabHost.setCurrentTabByTag(currentTabOption.getValue());
    tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
        public void onTabChanged(String tag) {
            if (!"delete".equals(tag)) {
                currentTabOption.setValue(tag);
            }
        }
    });

    final EditText editor = (EditText) findViewById(R.id.edit_bookmark_text);
    editor.setText(myBookmark.getText());
    final int len = editor.getText().length();
    editor.setSelection(len, len);

    final Button saveTextButton = (Button) findViewById(R.id.edit_bookmark_save_text_button);
    saveTextButton.setEnabled(false);
    saveTextButton.setText(myResource.getResource("saveText").getValue());
    saveTextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            myCollection.bindToService(EditBookmarkActivity.this, new Runnable() {
                public void run() {
                    myBookmark.setText(editor.getText().toString());
                    myCollection.saveBookmark(myBookmark);
                    saveTextButton.setEnabled(false);
                }
            });
        }
    });
    editor.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence sequence, int start, int before, int count) {
            final String originalText = myBookmark.getText();
            saveTextButton.setEnabled(!originalText.equals(editor.getText().toString()));
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });

    final Button deleteButton = (Button) findViewById(R.id.edit_bookmark_delete_button);
    deleteButton.setText(myResource.getResource("deleteBookmark").getValue());
    deleteButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            myCollection.bindToService(EditBookmarkActivity.this, new Runnable() {
                public void run() {
                    myCollection.deleteBookmark(myBookmark);
                    finish();
                }
            });
        }
    });
}

From source file:org.de.jmg.jmgphotouploader._MainActivity.java

private void initDisplay() {
    setContentView(R.layout.activity_main);

    lv = new ZoomExpandableListview(this); //FindViewById<ExpandableListView> (Resource.Id.lvItems);
    this.addContentView(lv,
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    lv.setChoiceMode(ExpandableListView.CHOICE_MODE_MULTIPLE);
    lv.setClickable(true);/*from  www.j a  v a  2 s.c  o  m*/
    lv.setFocusable(true);
    lv.setFocusableInTouchMode(true);

}

From source file:com.egoclean.testpregnancy.util.ActivityHelper.java

/**
 * Adds an action bar button to the compatibility action bar (on phones).
 *//*from  ww w  .  j a va  2s. co  m*/
private View addActionButtonCompat(int iconResId, int textResId, View.OnClickListener clickListener,
        boolean separatorAfter) {
    final ViewGroup actionBar = getActionBarCompat();
    if (actionBar == null) {
        return null;
    }

    // Create the separator
    ImageView separator = new ImageView(mActivity, null, R.attr.actionbarCompatSeparatorStyle);
    separator.setLayoutParams(new ViewGroup.LayoutParams(2, ViewGroup.LayoutParams.FILL_PARENT));

    // Create the button
    ImageButton actionButton = new ImageButton(mActivity, null, R.attr.actionbarCompatButtonStyle);
    actionButton.setLayoutParams(new ViewGroup.LayoutParams(
            (int) mActivity.getResources().getDimension(R.dimen.actionbar_compat_height),
            ViewGroup.LayoutParams.FILL_PARENT));
    actionButton.setImageResource(iconResId);
    actionButton.setScaleType(ImageView.ScaleType.CENTER);
    actionButton.setContentDescription(mActivity.getResources().getString(textResId));
    actionButton.setOnClickListener(clickListener);

    // Add separator and button to the action bar in the desired order

    if (!separatorAfter) {
        actionBar.addView(separator);
    }

    actionBar.addView(actionButton);

    if (separatorAfter) {
        actionBar.addView(separator);
    }

    return actionButton;
}

From source file:org.mitre.svmp.activities.AppRTCVideoActivity.java

@Override
protected void connectToRoom() {
    // Uncomment to get ALL WebRTC tracing and SENSITIVE libjingle logging.
    // Logging.enableTracing(
    // "/sdcard/trace.txt",
    // EnumSet.of(Logging.TraceLevel.TRACE_ALL),
    // Logging.Severity.LS_SENSITIVE);

    Point deviceDisplaySize = new Point();
    // displaySize.set(720, 1280);
    getWindowManager().getDefaultDisplay().getSize(deviceDisplaySize);

    Point displaySize = new Point();
    displaySize.set(deviceDisplaySize.x, deviceDisplaySize.y * (16 / 9));

    // displaySize.set(720, 1280);

    vsv = new VideoStreamsView(this, displaySize, performanceAdapter);
    vsv.setPreserveEGLContextOnPause(true);
    vsv.setBackgroundColor(Color.WHITE); // start this VideoStreamsView
    // with a color of dark gray

    createTopPanel();/*  ww w .j a  v a 2s  . c  o m*/

    setContentView(vsv);

    addContentView(ll,
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 50 * deviceDisplaySize.y / 1280));
    addContentView(scrollBtnsRLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    // addContentView(view, params);

    // vsvProgrssBar.setVisibility(View.INVISIBLE);

    touchHandler = new TouchHandler(this, displaySize, performanceAdapter);
    rotationHandler = new RotationHandler(this);
    keyHandler = new KeyHandler(this);
    configHandler = new ConfigHandler(this);

    AppRTCHelper.abortUnless(PeerConnectionFactory.initializeAndroidGlobals(this),
            "Failed to initializeAndroidGlobals");

    // Create observers.
    sdpObserver = new SDPObserver(this);
    // sdpaObserver = new SDPAObserver(this);
    pcObserver = new PCObserver(this);

    sdpMediaConstraints = new MediaConstraints();
    sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveAudio", "true"));
    sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveVideo", "true"));

    super.connectToRoom();
}

From source file:com.egoclean.testpregnancy.util.ActivityHelper.java

/**
 * Adds an action button to the compatibility action bar, using menu information from a
 * {@link android.view.MenuItem}. If the menu item ID is <code>menu_refresh</code>, the menu item's state
 * can be changed to show a loading spinner using
 * {@link ActivityHelper#setRefreshActionButtonCompatState(boolean)}.
 *//*from w w  w. j  a v a  2s  . c o m*/
private View addActionButtonCompatFromMenuItem(final MenuItem item) {
    final ViewGroup actionBar = getActionBarCompat();
    if (actionBar == null) {
        return null;
    }

    // Create the separator
    ImageView separator = new ImageView(mActivity, null, R.attr.actionbarCompatSeparatorStyle);
    separator.setLayoutParams(new ViewGroup.LayoutParams(2, ViewGroup.LayoutParams.FILL_PARENT));

    // Create the button
    ImageButton actionButton = new ImageButton(mActivity, null, R.attr.actionbarCompatButtonStyle);
    actionButton.setId(item.getItemId());
    actionButton.setLayoutParams(new ViewGroup.LayoutParams(
            (int) mActivity.getResources().getDimension(R.dimen.actionbar_compat_height),
            ViewGroup.LayoutParams.FILL_PARENT));
    actionButton.setImageDrawable(item.getIcon());
    actionButton.setScaleType(ImageView.ScaleType.CENTER);
    actionButton.setContentDescription(item.getTitle());
    actionButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            mActivity.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item);
        }
    });

    actionBar.addView(separator);
    actionBar.addView(actionButton);

    if (item.getItemId() == R.id.menu_refresh) {
        // Refresh buttons should be stateful, and allow for indeterminate progress indicators,
        // so add those.
        int buttonWidth = mActivity.getResources().getDimensionPixelSize(R.dimen.actionbar_compat_height);
        int buttonWidthDiv3 = buttonWidth / 3;
        ProgressBar indicator = new ProgressBar(mActivity, null, R.attr.actionbarCompatProgressIndicatorStyle);
        LinearLayout.LayoutParams indicatorLayoutParams = new LinearLayout.LayoutParams(buttonWidthDiv3,
                buttonWidthDiv3);
        indicatorLayoutParams.setMargins(buttonWidthDiv3, buttonWidthDiv3, buttonWidth - 2 * buttonWidthDiv3,
                0);
        indicator.setLayoutParams(indicatorLayoutParams);
        indicator.setVisibility(View.GONE);
        indicator.setId(R.id.menu_refresh_progress);
        actionBar.addView(indicator);
    }

    return actionButton;
}

From source file:lewa.support.v7.internal.widget.ScrollingTabContainerView.java

public ScrollingTabContainerView(Context context) {
    super(context);
    ///LEWA BEGIN      
    mInflater = LayoutInflater.from(context);
    ///LEWA END/*from  w w w  . java  2  s.  c o  m*/
    setHorizontalScrollBarEnabled(false);

    ActionBarPolicy abp = ActionBarPolicy.get(context);
    setContentHeight(abp.getTabContainerHeight());
    mStackedTabMaxWidth = abp.getStackedTabMaxWidth();

    ///LEWA BEGIN
    Injector.adjustContainerHeight(context, abp, this);
    ///LEWA END
    mTabLayout = createTabLayout();
    ///LEWA BEGIN
    //addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
    //ViewGroup.LayoutParams.MATCH_PARENT));
    if (true) {
        Injector.initView(context, this);
    } else {
        addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
    }
    ///LEWA END
    ///LEWA BEGIN
    Injector.initial(context, this);
    ///LEWA END
}

From source file:com.liangxun.university.huanxin.chat.activity.ChatActivity.java

/**
 * ?//from   ww w.  j  av  a  2s .co m
 */
private void Init_Point() {

    pointViews = new ArrayList<ImageView>();
    ImageView imageView;
    for (int i = 0; i < views.size(); i++) {
        imageView = new ImageView(this);
        imageView.setBackgroundResource(R.drawable.d1);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(new ViewGroup.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT));
        layoutParams.leftMargin = 10;
        layoutParams.rightMargin = 10;
        layoutParams.width = 8;
        layoutParams.height = 8;
        layout_point.addView(imageView, layoutParams);
        //            if (i == 0 || i == views.size() - 1) {
        //                imageView.setVisibility(View.GONE);
        //            }
        if (i == 0) {
            imageView.setBackgroundResource(R.drawable.d2);
        }
        pointViews.add(imageView);

    }
}

From source file:lewa.support.v7.internal.widget.ScrollingTabContainerView.java

private void performCollapse() {
    if (isCollapsed())
        return;/*  w  w w  .j a  v a  2 s . com*/

    if (mTabSpinner == null) {
        mTabSpinner = createSpinner();
    }
    removeView(mTabLayout);
    addView(mTabSpinner, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    if (mTabSpinner.getAdapter() == null) {
        mTabSpinner.setAdapter(new TabAdapter());
    }
    if (mTabSelector != null) {
        removeCallbacks(mTabSelector);
        mTabSelector = null;
    }
    mTabSpinner.setSelection(mSelectedTabIndex);
}

From source file:lewa.support.v7.internal.widget.ScrollingTabContainerView.java

private boolean performExpand() {
    if (!isCollapsed())
        return false;

    removeView(mTabSpinner);/* w  ww. j ava  2 s  .  c o m*/
    addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    setTabSelected(mTabSpinner.getSelectedItemPosition());
    return false;
}

From source file:mroza.forms.ChooseProgramActivity.java

private void enableShowAllButton(boolean enable) {
    LinearLayout layout = (LinearLayout) findViewById(R.id.LayoutGrid);
    Button button = (Button) findViewById(R.id.show_all_programs_button_id);

    if (enable && button == null) {
        button = new Button(this);
        button.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        button.setText(R.string.show_all_programs);
        button.setId(R.id.show_all_programs_button_id);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                List<ChildTable> childTables;
                clearFilters(true);//  w  ww.  j a va2  s  .c  o m
                clearSearchField();

                Term selectedTerm = getSelectedTerm();
                childTables = ChildTablesRepository.getChildTableByTerm(ChooseProgramActivity.this,
                        selectedTerm, child);
                handleListViewBehavior(childTables, selectedTerm);

                enableShowAllButton(false);
            }
        });
        layout.addView(button, 1);
    } else if (!enable && button != null) {
        layout.removeView(button);
    }
}