Search in sources :

Example 51 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project DragListView by woxblom.

the class BoardView method addColumnList.

public DragItemRecyclerView addColumnList(final DragItemAdapter adapter, final View header, boolean hasFixedItemSize) {
    final DragItemRecyclerView recyclerView = (DragItemRecyclerView) LayoutInflater.from(getContext()).inflate(R.layout.drag_item_recycler_view, this, false);
    recyclerView.setId(getColumnCount());
    recyclerView.setHorizontalScrollBarEnabled(false);
    recyclerView.setVerticalScrollBarEnabled(false);
    recyclerView.setMotionEventSplittingEnabled(false);
    recyclerView.setDragItem(mDragItem);
    recyclerView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.setHasFixedSize(hasFixedItemSize);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setDragItemListener(new DragItemRecyclerView.DragItemListener() {

        @Override
        public void onDragStarted(int itemPosition, float x, float y) {
            mDragStartColumn = getColumnOfList(recyclerView);
            mDragStartRow = itemPosition;
            mCurrentRecyclerView = recyclerView;
            mDragItem.setOffset(((View) mCurrentRecyclerView.getParent()).getX(), mCurrentRecyclerView.getY());
            if (mBoardListener != null) {
                mBoardListener.onItemDragStarted(mDragStartColumn, mDragStartRow);
            }
            invalidate();
        }

        @Override
        public void onDragging(int itemPosition, float x, float y) {
            int column = getColumnOfList(recyclerView);
            boolean positionChanged = column != mLastDragColumn || itemPosition != mLastDragRow;
            if (mBoardListener != null && positionChanged) {
                mLastDragColumn = column;
                mLastDragRow = itemPosition;
                mBoardListener.onItemChangedPosition(mDragStartColumn, mDragStartRow, column, itemPosition);
            }
        }

        @Override
        public void onDragEnded(int newItemPosition) {
            mLastDragColumn = NO_POSITION;
            mLastDragRow = NO_POSITION;
            if (mBoardListener != null) {
                mBoardListener.onItemDragEnded(mDragStartColumn, mDragStartRow, getColumnOfList(recyclerView), newItemPosition);
            }
        }
    });
    recyclerView.setDragItemCallback(new DragItemRecyclerView.DragItemCallback() {

        @Override
        public boolean canDragItemAtPosition(int dragPosition) {
            int column = getColumnOfList(recyclerView);
            return mBoardCallback == null || mBoardCallback.canDragItemAtPosition(column, dragPosition);
        }

        @Override
        public boolean canDropItemAtPosition(int dropPosition) {
            int column = getColumnOfList(recyclerView);
            return mBoardCallback == null || mBoardCallback.canDropItemAtPosition(mDragStartColumn, mDragStartRow, column, dropPosition);
        }
    });
    recyclerView.setAdapter(adapter);
    recyclerView.setDragEnabled(mDragEnabled);
    adapter.setDragStartedListener(new DragItemAdapter.DragStartCallback() {

        @Override
        public boolean startDrag(View itemView, long itemId) {
            return recyclerView.startDrag(itemView, itemId, getRelativeViewTouchX((View) recyclerView.getParent()), getRelativeViewTouchY(recyclerView));
        }

        @Override
        public boolean isDragging() {
            return recyclerView.isDragging();
        }
    });
    LinearLayout layout = new LinearLayout(getContext());
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setLayoutParams(new LayoutParams(mColumnWidth, LayoutParams.MATCH_PARENT));
    if (header != null) {
        layout.addView(header);
        mHeaders.add(header);
    }
    layout.addView(recyclerView);
    mLists.add(recyclerView);
    mColumnLayout.addView(layout);
    return recyclerView;
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) LinearLayout(android.widget.LinearLayout)

Example 52 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project AgileDev by LZ9.

the class ItemDecorationTestActivity method getExpandView.

/**
 * 获取扩展view
 */
private View getExpandView() {
    LinearLayout linearLayout = new LinearLayout(getContext());
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    linearLayout.setLayoutParams(layoutParams);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    // 方向
    final TextView orientationTv = getTextView(R.string.drag_orientation);
    orientationTv.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showOrientationPopupWindow(v);
        }
    });
    linearLayout.addView(orientationTv, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    // 布局
    final TextView LayoutManagerTv = getTextView(R.string.drag_layout_manager);
    LayoutManagerTv.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showLayoutManagerPopupWindow(v);
        }
    });
    linearLayout.addView(LayoutManagerTv, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    return linearLayout;
}
Also used : TextView(android.widget.TextView) BindView(butterknife.BindView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Example 53 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project Osmand by osmandapp.

the class POIMapLayer method showText.

private static void showText(final Context ctx, final OsmandApplication app, final String text, String title) {
    final Dialog dialog = new Dialog(ctx, app.getSettings().isLightContent() ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
    LinearLayout ll = new LinearLayout(ctx);
    ll.setOrientation(LinearLayout.VERTICAL);
    final Toolbar topBar = new Toolbar(ctx);
    topBar.setClickable(true);
    Drawable back = app.getIconsCache().getIcon(R.drawable.ic_arrow_back);
    topBar.setNavigationIcon(back);
    topBar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
    topBar.setTitle(title);
    topBar.setBackgroundColor(ContextCompat.getColor(ctx, getResIdFromAttribute(ctx, R.attr.pstsTabBackground)));
    topBar.setTitleTextColor(ContextCompat.getColor(ctx, getResIdFromAttribute(ctx, R.attr.pstsTextColor)));
    topBar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(final View v) {
            dialog.dismiss();
        }
    });
    final TextView textView = new TextView(ctx);
    LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    int textMargin = dpToPx(app, 10f);
    boolean light = app.getSettings().isLightContent();
    textView.setLayoutParams(llTextParams);
    textView.setPadding(textMargin, textMargin, textMargin, textMargin);
    textView.setTextSize(16);
    textView.setTextColor(ContextCompat.getColor(app, light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark));
    textView.setAutoLinkMask(Linkify.ALL);
    textView.setLinksClickable(true);
    textView.setText(text);
    ScrollView scrollView = new ScrollView(ctx);
    ll.addView(topBar);
    LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0);
    lp.weight = 1;
    ll.addView(scrollView, lp);
    scrollView.addView(textView);
    dialog.setContentView(ll);
    dialog.setCancelable(true);
    dialog.show();
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) Drawable(android.graphics.drawable.Drawable) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) Paint(android.graphics.Paint) LayoutParams(android.widget.LinearLayout.LayoutParams) ScrollView(android.widget.ScrollView) Dialog(android.app.Dialog) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 54 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project ttdj by soonphe.

the class RecycleViewDivider method drawVertical.

// 绘制纵向 item 分割线
private void drawVertical(Canvas canvas, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getMeasuredHeight() - parent.getPaddingBottom();
    final int childSize = parent.getChildCount();
    for (int i = 0; i < childSize; i++) {
        final View child = parent.getChildAt(i);
        RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int left = child.getRight() + layoutParams.rightMargin;
        final int right = left + mDividerHeight;
        if (mDivider != null) {
            mDivider.setBounds(left, top, right, bottom);
            mDivider.draw(canvas);
        }
        if (mPaint != null) {
            canvas.drawRect(left, top, right, bottom, mPaint);
        }
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) Paint(android.graphics.Paint)

Example 55 with LayoutParams

use of android.support.v7.app.ActionBar.LayoutParams in project opacclient by opacapp.

the class AccountSwitcherNavigationView method init.

private void init() {
    accountsList = new RecyclerView(getContext());
    accountsList.setLayoutManager(new LinearLayoutManager(getContext()));
    addView(accountsList);
    LayoutParams params = (FrameLayout.LayoutParams) accountsList.getLayoutParams();
    params.setMargins(0, getResources().getDimensionPixelSize(R.dimen.navigation_drawer_header_height), 0, 0);
    // https://code.google.com/p/android/issues/detail?id=28057
    params.gravity = Gravity.BOTTOM;
    TypedArray a = getContext().obtainStyledAttributes(new int[] { android.R.attr.windowBackground });
    accountsList.setBackgroundResource(a.getResourceId(0, 0));
    a.recycle();
    accountsList.setPadding(0, getResources().getDimensionPixelSize(R.dimen.list_top_padding), 0, 0);
    accountsList.setClipToPadding(false);
    accountsList.setVisibility(View.GONE);
}
Also used : TypedArray(android.content.res.TypedArray) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

View (android.view.View)140 RecyclerView (android.support.v7.widget.RecyclerView)127 TextView (android.widget.TextView)46 ImageView (android.widget.ImageView)38 ViewGroup (android.view.ViewGroup)33 LinearLayout (android.widget.LinearLayout)27 LayoutParams (android.support.v7.widget.RecyclerView.LayoutParams)17 Paint (android.graphics.Paint)15 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)15 FrameLayout (android.widget.FrameLayout)15 BindView (butterknife.BindView)12 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)11 Toolbar (android.support.v7.widget.Toolbar)11 Rect (android.graphics.Rect)9 EditText (android.widget.EditText)9 OrientationHelperEx (com.alibaba.android.vlayout.OrientationHelperEx)9 AdapterView (android.widget.AdapterView)8 RelativeLayout (android.widget.RelativeLayout)8 VirtualLayoutManager (com.alibaba.android.vlayout.VirtualLayoutManager)8 SuppressLint (android.annotation.SuppressLint)7