Search in sources :

Example 96 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project android_frameworks_base by ResurrectionRemix.

the class Dialog method dispatchPopulateAccessibilityEvent.

@Override
public boolean dispatchPopulateAccessibilityEvent(@NonNull AccessibilityEvent event) {
    event.setClassName(getClass().getName());
    event.setPackageName(mContext.getPackageName());
    LayoutParams params = getWindow().getAttributes();
    boolean isFullScreen = (params.width == LayoutParams.MATCH_PARENT) && (params.height == LayoutParams.MATCH_PARENT);
    event.setFullScreen(isFullScreen);
    return false;
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams)

Example 97 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SpacePreference method onBindViewHolder.

@Override
public void onBindViewHolder(PreferenceViewHolder view) {
    super.onBindViewHolder(view);
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, mHeight);
    view.itemView.setLayoutParams(params);
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams)

Example 98 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project android_frameworks_base by ResurrectionRemix.

the class FrameworkActionBar method createMenuPopup.

/**
     * Creates a Popup and adds it to the content frame. It also adds another {@link FrameLayout} to
     * the content frame which shall serve as the new content root.
     */
@Override
public void createMenuPopup() {
    if (!isOverflowPopupNeeded()) {
        return;
    }
    DisplayMetrics metrics = mBridgeContext.getMetrics();
    MenuBuilder menu = mActionBar.getMenuBuilder();
    OverflowMenuAdapter adapter = new OverflowMenuAdapter(menu, mActionBar.getPopupContext());
    ListView listView = new ListView(mActionBar.getPopupContext(), null, R.attr.dropDownListViewStyle);
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(measureContentWidth(adapter), LayoutParams.WRAP_CONTENT);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_END);
    if (mActionBar.isSplit()) {
        layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        layoutParams.bottomMargin = getActionBarHeight() + mActionBar.getMenuPopupMargin();
    } else {
        layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
        layoutParams.topMargin = getActionBarHeight() + mActionBar.getMenuPopupMargin();
    }
    layoutParams.setMarginEnd(getPixelValue("5dp", metrics));
    listView.setLayoutParams(layoutParams);
    listView.setAdapter(adapter);
    final TypedArray a = mActionBar.getPopupContext().obtainStyledAttributes(null, R.styleable.PopupWindow, R.attr.popupMenuStyle, 0);
    listView.setBackground(a.getDrawable(R.styleable.PopupWindow_popupBackground));
    listView.setDivider(a.getDrawable(R.attr.actionBarDivider));
    a.recycle();
    listView.setElevation(mActionBar.getMenuPopupElevation());
    assert mEnclosingLayout != null : "Unable to find view to attach ActionMenuPopup.";
    mEnclosingLayout.addView(listView);
}
Also used : ListView(android.widget.ListView) LayoutParams(android.view.ViewGroup.LayoutParams) TypedArray(android.content.res.TypedArray) RelativeLayout(android.widget.RelativeLayout) DisplayMetrics(android.util.DisplayMetrics) MenuBuilder(com.android.internal.view.menu.MenuBuilder)

Example 99 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project android_frameworks_base by ResurrectionRemix.

the class RenderSessionImpl method createViewInfo.

/**
     * Creates a {@link ViewInfo} for the view. The {@code ViewInfo} corresponding to the children
     * of the {@code view} are not created. Consequently, the children of {@code ViewInfo} is not
     * set.
     * @param offset an offset for the view bounds. Used only if view is part of the content frame.
     */
private ViewInfo createViewInfo(View view, int offset, boolean setExtendedInfo, boolean isContentFrame) {
    if (view == null) {
        return null;
    }
    ViewParent parent = view.getParent();
    ViewInfo result;
    if (isContentFrame) {
        // Account for parent scroll values when calculating the bounding box
        int scrollX = parent != null ? ((View) parent).getScrollX() : 0;
        int scrollY = parent != null ? ((View) parent).getScrollY() : 0;
        // The view is part of the layout added by the user. Hence,
        // the ViewCookie may be obtained only through the Context.
        result = new ViewInfo(view.getClass().getName(), getContext().getViewKey(view), -scrollX + view.getLeft(), -scrollY + view.getTop() + offset, -scrollX + view.getRight(), -scrollY + view.getBottom() + offset, view, view.getLayoutParams());
    } else {
        // We are part of the system decor.
        SystemViewInfo r = new SystemViewInfo(view.getClass().getName(), getViewKey(view), view.getLeft(), view.getTop(), view.getRight(), view.getBottom(), view, view.getLayoutParams());
        result = r;
        // 3. The overflow popup button.
        if (view instanceof ListMenuItemView) {
            // Mark 2.
            // All menus in the popup are of type ListMenuItemView.
            r.setViewType(ViewType.ACTION_BAR_OVERFLOW_MENU);
        } else {
            // Mark 3.
            ViewGroup.LayoutParams lp = view.getLayoutParams();
            if (lp instanceof ActionMenuView.LayoutParams && ((ActionMenuView.LayoutParams) lp).isOverflowButton) {
                r.setViewType(ViewType.ACTION_BAR_OVERFLOW);
            } else {
                // actionProviderClass.
                while (parent != mViewRoot && parent instanceof ViewGroup) {
                    if (parent instanceof ActionMenuView) {
                        r.setViewType(ViewType.ACTION_BAR_MENU);
                        break;
                    }
                    parent = parent.getParent();
                }
            }
        }
    }
    if (setExtendedInfo) {
        MarginLayoutParams marginParams = null;
        LayoutParams params = view.getLayoutParams();
        if (params instanceof MarginLayoutParams) {
            marginParams = (MarginLayoutParams) params;
        }
        result.setExtendedInfo(view.getBaseline(), marginParams != null ? marginParams.leftMargin : 0, marginParams != null ? marginParams.topMargin : 0, marginParams != null ? marginParams.rightMargin : 0, marginParams != null ? marginParams.bottomMargin : 0);
    }
    return result;
}
Also used : ListMenuItemView(com.android.internal.view.menu.ListMenuItemView) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) LayoutParams(android.view.ViewGroup.LayoutParams) ViewParent(android.view.ViewParent) ViewGroup(android.view.ViewGroup) LayoutParams(android.view.ViewGroup.LayoutParams) ActionMenuView(android.widget.ActionMenuView) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) ViewInfo(com.android.ide.common.rendering.api.ViewInfo)

Example 100 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project android_frameworks_base by ResurrectionRemix.

the class RenderSessionImpl method moveChild.

/**
     * Moves a view to a new parent at a given location
     * <p>
     * {@link #acquire(long)} must have been called before this.
     *
     * @throws IllegalStateException if the current context is different than the one owned by
     *      the scene, or if {@link #acquire(long)} was not called.
     *
     * @see RenderSession#moveChild(Object, Object, int, Map, IAnimationListener)
     */
public Result moveChild(final ViewGroup newParentView, final View childView, final int index, Map<String, String> layoutParamsMap, final IAnimationListener listener) {
    checkLock();
    invalidateRenderingSize();
    LayoutParams layoutParams = null;
    if (layoutParamsMap != null) {
        // need to create a new LayoutParams object for the new parent.
        layoutParams = newParentView.generateLayoutParams(new BridgeLayoutParamsMapAttributes(layoutParamsMap));
    }
    // get the current parent of the view that needs to be moved.
    final ViewGroup previousParent = (ViewGroup) childView.getParent();
    if (listener != null) {
        final LayoutParams params = layoutParams;
        // parent views are different we fake the animation through a no animation thread.
        if (previousParent != newParentView) {
            new Thread("not animated moveChild") {

                @Override
                public void run() {
                    Result result = moveView(previousParent, newParentView, childView, index, params);
                    if (!result.isSuccess()) {
                        listener.done(result);
                    }
                    // ready to do the work, acquire the scene.
                    result = acquire(250);
                    if (!result.isSuccess()) {
                        listener.done(result);
                        return;
                    }
                    try {
                        result = render(false);
                        if (result.isSuccess()) {
                            listener.onNewFrame(RenderSessionImpl.this.getSession());
                        }
                    } finally {
                        release();
                    }
                    listener.done(result);
                }
            }.start();
        } else {
            new AnimationThread(this, "moveChild", listener) {

                @Override
                public Result preAnimation() {
                    // set up the transition for the parent.
                    LayoutTransition transition = new LayoutTransition();
                    previousParent.setLayoutTransition(transition);
                    // tweak the animation durations and start delays (to match the duration of
                    // animation playing just before).
                    // Note: Cannot user Animation.setDuration() directly. Have to set it
                    // on the LayoutTransition.
                    transition.setDuration(LayoutTransition.DISAPPEARING, 100);
                    // CHANGE_DISAPPEARING plays after DISAPPEARING
                    transition.setStartDelay(LayoutTransition.CHANGE_DISAPPEARING, 100);
                    transition.setDuration(LayoutTransition.CHANGE_DISAPPEARING, 100);
                    transition.setDuration(LayoutTransition.CHANGE_APPEARING, 100);
                    // CHANGE_APPEARING plays after CHANGE_APPEARING
                    transition.setStartDelay(LayoutTransition.APPEARING, 100);
                    transition.setDuration(LayoutTransition.APPEARING, 100);
                    return moveView(previousParent, newParentView, childView, index, params);
                }

                @Override
                public void postAnimation() {
                    previousParent.setLayoutTransition(null);
                    newParentView.setLayoutTransition(null);
                }
            }.start();
        }
        // always return success since the real status will come through the listener.
        return SUCCESS.createResult(layoutParams);
    }
    Result result = moveView(previousParent, newParentView, childView, index, layoutParams);
    if (!result.isSuccess()) {
        return result;
    }
    result = render(false);
    if (layoutParams != null && result.isSuccess()) {
        result = result.getCopyWithData(layoutParams);
    }
    return result;
}
Also used : BridgeLayoutParamsMapAttributes(com.android.layoutlib.bridge.android.BridgeLayoutParamsMapAttributes) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) LayoutParams(android.view.ViewGroup.LayoutParams) AnimationThread(android.animation.AnimationThread) ViewGroup(android.view.ViewGroup) LayoutTransition(android.animation.LayoutTransition) AnimationThread(android.animation.AnimationThread) Result(com.android.ide.common.rendering.api.Result)

Aggregations

LayoutParams (android.view.ViewGroup.LayoutParams)263 TextView (android.widget.TextView)54 View (android.view.View)50 ViewGroup (android.view.ViewGroup)50 FrameLayout (android.widget.FrameLayout)35 LinearLayout (android.widget.LinearLayout)32 ImageView (android.widget.ImageView)30 Test (org.junit.Test)26 ListView (android.widget.ListView)22 ScrollView (android.widget.ScrollView)22 Paint (android.graphics.Paint)21 MarginLayoutParams (android.view.ViewGroup.MarginLayoutParams)19 Context (android.content.Context)18 AdapterView (android.widget.AdapterView)17 RelativeLayout (android.widget.RelativeLayout)14 DisplayMetrics (android.util.DisplayMetrics)12 CheckedTextView (android.widget.CheckedTextView)12 Rect (android.graphics.Rect)9 ViewParent (android.view.ViewParent)9 TypedArray (android.content.res.TypedArray)8