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;
}
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;
}
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();
}
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);
}
}
}
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);
}
Aggregations