Search in sources :

Example 91 with LinearLayout

use of android.widget.LinearLayout in project robolectric by robolectric.

the class ShadowViewTest method testHasNullLayoutParamsUntilAddedToParent.

@Test
public void testHasNullLayoutParamsUntilAddedToParent() throws Exception {
    assertThat(view.getLayoutParams()).isNull();
    new LinearLayout(RuntimeEnvironment.application).addView(view);
    assertThat(view.getLayoutParams()).isNotNull();
}
Also used : LinearLayout(android.widget.LinearLayout) Test(org.junit.Test)

Example 92 with LinearLayout

use of android.widget.LinearLayout in project robolectric by robolectric.

the class ShadowViewTest method shouldInflateMergeRootedLayoutAndNotCreateReferentialLoops.

@Test
public void shouldInflateMergeRootedLayoutAndNotCreateReferentialLoops() throws Exception {
    LinearLayout root = new LinearLayout(RuntimeEnvironment.application);
    LinearLayout.inflate(RuntimeEnvironment.application, R.layout.inner_merge, root);
    for (int i = 0; i < root.getChildCount(); i++) {
        View child = root.getChildAt(i);
        assertNotSame(root, child);
    }
}
Also used : LinearLayout(android.widget.LinearLayout) Point(android.graphics.Point) Test(org.junit.Test)

Example 93 with LinearLayout

use of android.widget.LinearLayout in project xabber-android by redsolution.

the class ContactListFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.contact_list_fragment, container, false);
    // to avoid strange bug on some 4.x androids
    view.setBackgroundColor(ColorManager.getInstance().getContactListBackgroundColor());
    listView = (ListView) view.findViewById(android.R.id.list);
    listView.setOnItemClickListener(this);
    listView.setItemsCanFocus(true);
    registerForContextMenu(listView);
    adapter = new ContactListAdapter(getActivity(), this, this);
    listView.setAdapter(adapter);
    infoView = view.findViewById(R.id.info);
    connectedView = infoView.findViewById(R.id.connected);
    disconnectedView = infoView.findViewById(R.id.disconnected);
    textView = (TextView) infoView.findViewById(R.id.text);
    buttonView = (Button) infoView.findViewById(R.id.button);
    animation = AnimationUtils.loadAnimation(getActivity(), R.anim.connection);
    accountActionButtonsAdapter = new AccountActionButtonsAdapter(getActivity(), this, (LinearLayout) view.findViewById(R.id.account_action_buttons));
    accountActionButtonsAdapter.onChange();
    actionButtonsContainer = view.findViewById(R.id.account_action_buttons_container);
    scrollToChatsActionButtonContainer = view.findViewById(R.id.fab_up_container);
    scrollToChatsActionButtonContainer.setOnClickListener(this);
    scrollToChatsActionButtonContainer.setVisibility(View.GONE);
    scrollToChatsActionButton = (FloatingActionButton) view.findViewById(R.id.fab_up);
    accountPainter = ColorManager.getInstance().getAccountPainter();
    scrollToChatsActionButton.setColorNormal(accountPainter.getDefaultMainColor());
    scrollToChatsActionButton.setColorPressed(accountPainter.getDefaultDarkColor());
    return view;
}
Also used : AccountActionButtonsAdapter(com.xabber.android.ui.adapter.AccountActionButtonsAdapter) ContactListAdapter(com.xabber.android.ui.adapter.ContactListAdapter) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) LinearLayout(android.widget.LinearLayout)

Example 94 with LinearLayout

use of android.widget.LinearLayout in project material by rey5137.

the class ListPopupWindow method buildDropDown.

/**
     * <p>Builds the popup window's content and returns the height the popup
     * should have. Returns -1 when the content already exists.</p>
     *
     * @return the content's height or -1 if content already exists
     */
private int buildDropDown() {
    int otherHeights = 0;
    if (mDropDownList == null) {
        ViewGroup dropDownView;
        Context context = mContext;
        /**
             * This Runnable exists for the sole purpose of checking if the view layout has got
             * completed and if so call showDropDown to display the drop down. This is used to show
             * the drop down as soon as possible after user opens up the search dialog, without
             * waiting for the normal UI pipeline to do it's job which is slower than this method.
             */
        mShowDropDownRunnable = new Runnable() {

            public void run() {
                // View layout should be all done before displaying the drop down.
                View view = getAnchorView();
                if (view != null && view.getWindowToken() != null) {
                    show();
                }
            }
        };
        mDropDownList = new DropDownListView(context, !mModal);
        if (mDropDownListHighlight != null) {
            mDropDownList.setSelector(mDropDownListHighlight);
        }
        mDropDownList.setAdapter(mAdapter);
        mDropDownList.setOnItemClickListener(mItemClickListener);
        mDropDownList.setFocusable(true);
        mDropDownList.setFocusableInTouchMode(true);
        mDropDownList.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                if (position != -1) {
                    DropDownListView dropDownList = mDropDownList;
                    if (dropDownList != null) {
                        dropDownList.mListSelectionHidden = false;
                    }
                }
            }

            public void onNothingSelected(AdapterView<?> parent) {
            }
        });
        mDropDownList.setOnScrollListener(mScrollListener);
        if (mItemSelectedListener != null) {
            mDropDownList.setOnItemSelectedListener(mItemSelectedListener);
        }
        dropDownView = mDropDownList;
        View hintView = mPromptView;
        if (hintView != null) {
            // if a hint has been specified, we accomodate more space for it and
            // add a text view in the drop down menu, at the bottom of the list
            LinearLayout hintContainer = new LinearLayout(context);
            hintContainer.setOrientation(LinearLayout.VERTICAL);
            LinearLayout.LayoutParams hintParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1.0f);
            switch(mPromptPosition) {
                case POSITION_PROMPT_BELOW:
                    hintContainer.addView(dropDownView, hintParams);
                    hintContainer.addView(hintView);
                    break;
                case POSITION_PROMPT_ABOVE:
                    hintContainer.addView(hintView);
                    hintContainer.addView(dropDownView, hintParams);
                    break;
                default:
                    Log.e(TAG, "Invalid hint position " + mPromptPosition);
                    break;
            }
            // measure the hint's height to find how much more vertical space
            // we need to add to the drop down's height
            int widthSpec = MeasureSpec.makeMeasureSpec(mDropDownWidth, MeasureSpec.AT_MOST);
            int heightSpec = MeasureSpec.UNSPECIFIED;
            hintView.measure(widthSpec, heightSpec);
            hintParams = (LinearLayout.LayoutParams) hintView.getLayoutParams();
            otherHeights = hintView.getMeasuredHeight() + hintParams.topMargin + hintParams.bottomMargin;
            dropDownView = hintContainer;
        }
        mPopup.setContentView(dropDownView);
    } else {
        final View view = mPromptView;
        if (view != null) {
            LinearLayout.LayoutParams hintParams = (LinearLayout.LayoutParams) view.getLayoutParams();
            otherHeights = view.getMeasuredHeight() + hintParams.topMargin + hintParams.bottomMargin;
        }
    }
    // getMaxAvailableHeight() subtracts the padding, so we put it back
    // to get the available height for the whole window
    int padding = 0;
    Drawable background = mPopup.getBackground();
    if (background != null) {
        background.getPadding(mTempRect);
        padding = mTempRect.top + mTempRect.bottom;
        // background so that content will line up.
        if (!mDropDownVerticalOffsetSet) {
            mDropDownVerticalOffset = -mTempRect.top;
        }
    } else {
        mTempRect.setEmpty();
    }
    int systemBarsReservedSpace = 0;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        //  getMaxAvailableHeight() on Lollipop seems to ignore the system bars.
        systemBarsReservedSpace = Math.max(getSystemBarHeight("status_bar_height"), getSystemBarHeight("navigation_bar_height"));
    }
    // Max height available on the screen for a popup.
    boolean ignoreBottomDecorations = mPopup.getInputMethodMode() == PopupWindow.INPUT_METHOD_NOT_NEEDED;
    final int maxHeight = mPopup.getMaxAvailableHeight(getAnchorView(), mDropDownVerticalOffset) - systemBarsReservedSpace;
    if (mDropDownAlwaysVisible || mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
        return maxHeight + padding;
    }
    final int childWidthSpec;
    switch(mDropDownWidth) {
        case ViewGroup.LayoutParams.WRAP_CONTENT:
            childWidthSpec = MeasureSpec.makeMeasureSpec(mContext.getResources().getDisplayMetrics().widthPixels - (mTempRect.left + mTempRect.right), MeasureSpec.AT_MOST);
            break;
        case ViewGroup.LayoutParams.MATCH_PARENT:
            childWidthSpec = MeasureSpec.makeMeasureSpec(mContext.getResources().getDisplayMetrics().widthPixels - (mTempRect.left + mTempRect.right), MeasureSpec.EXACTLY);
            break;
        default:
            childWidthSpec = MeasureSpec.makeMeasureSpec(mDropDownWidth, MeasureSpec.EXACTLY);
            break;
    }
    final int listContent = mDropDownList.measureHeightOfChildrenCompat(childWidthSpec, 0, DropDownListView.NO_POSITION, maxHeight - otherHeights, -1);
    // the popup if it is not needed
    if (listContent > 0)
        otherHeights += padding;
    return listContent + otherHeights;
}
Also used : Context(android.content.Context) ViewGroup(android.view.ViewGroup) Drawable(android.graphics.drawable.Drawable) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) AdapterView(android.widget.AdapterView) LinearLayout(android.widget.LinearLayout)

Example 95 with LinearLayout

use of android.widget.LinearLayout in project cube-sdk by liaohuqiu.

the class TitleBaseFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup view = (ViewGroup) inflater.inflate(getFrameLayoutId(), null);
    LinearLayout contentContainer = (LinearLayout) view.findViewById(R.id.cube_mints_content_frame_content);
    mTitleHeaderBar = (TitleHeaderBar) view.findViewById(R.id.cube_mints_content_frame_title_header);
    if (enableDefaultBack()) {
        mTitleHeaderBar.setLeftOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
    } else {
        mTitleHeaderBar.getLeftViewContainer().setVisibility(View.INVISIBLE);
    }
    mContentContainer = contentContainer;
    View contentView = createView(inflater, view, savedInstanceState);
    contentView.setLayoutParams(new LinearLayout.LayoutParams(-1, -1));
    contentContainer.addView(contentView);
    return view;
}
Also used : ViewGroup(android.view.ViewGroup) OnClickListener(android.view.View.OnClickListener) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Aggregations

LinearLayout (android.widget.LinearLayout)1205 View (android.view.View)473 TextView (android.widget.TextView)455 ViewGroup (android.view.ViewGroup)203 ImageView (android.widget.ImageView)196 Button (android.widget.Button)167 ScrollView (android.widget.ScrollView)125 ListView (android.widget.ListView)100 LayoutInflater (android.view.LayoutInflater)90 FrameLayout (android.widget.FrameLayout)85 Context (android.content.Context)80 AdapterView (android.widget.AdapterView)74 EditText (android.widget.EditText)74 Intent (android.content.Intent)66 AbsListView (android.widget.AbsListView)58 LayoutParams (android.widget.LinearLayout.LayoutParams)48 RelativeLayout (android.widget.RelativeLayout)48 Bitmap (android.graphics.Bitmap)46 OnClickListener (android.view.View.OnClickListener)44 Drawable (android.graphics.drawable.Drawable)42