Java Code Examples for android.widget.LinearLayout.VERTICAL

The following are Jave code examples for showing how to use VERTICAL of the android.widget.LinearLayout class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: GitHub   File: HeaderRenderer.java   View Source Code Vote up 6 votes
/**
 * Gets a clipping rect for the header based on the margins of the header and the padding of the
 * recycler.
 * FIXME: Currently right margin in VERTICAL orientation and bottom margin in HORIZONTAL
 * orientation are clipped so they look accurate, but the headers are not being drawn at the
 * correctly smaller width and height respectively.
 *
 * @param recyclerView for which to provide a header
 * @param header       for clipping
 * @return a {@link Rect} for clipping a provided header to the padding of a recycler view
 */
private Rect getClipRectForHeader(RecyclerView recyclerView, View header) {
  Rect headerMargins = mDimensionCalculator.getMargins(header);
  if (mOrientationProvider.getOrientation(recyclerView) == LinearLayout.VERTICAL) {
    return new Rect(
        recyclerView.getPaddingLeft(),
        recyclerView.getPaddingTop(),
        recyclerView.getWidth() - recyclerView.getPaddingRight() - headerMargins.right,
        recyclerView.getHeight() - recyclerView.getPaddingBottom());
  } else {
    return new Rect(
        recyclerView.getPaddingLeft(),
        recyclerView.getPaddingTop(),
        recyclerView.getWidth() - recyclerView.getPaddingRight(),
        recyclerView.getHeight() - recyclerView.getPaddingBottom() - headerMargins.bottom);
  }
}
 
Example 2
Project: RvAdapter   File: HeaderRenderer.java   View Source Code Vote up 6 votes
/**
 * Initializes a clipping rect for the header based on the margins of the header and the padding of the
 * recycler.
 * FIXME: Currently right margin in VERTICAL orientation and bottom margin in HORIZONTAL
 * orientation are clipped so they look accurate, but the headers are not being drawn at the
 * correctly smaller width and height respectively.
 *
 * @param clipRect     {@link Rect} for clipping a provided header to the padding of a recycler view
 * @param recyclerView for which to provide a header
 * @param header       for clipping
 */
private void initClipRectForHeader(Rect clipRect, RecyclerView recyclerView, View header) {
    mDimensionCalculator.initMargins(clipRect, header);
    if (mOrientationProvider.getOrientation(recyclerView) == LinearLayout.VERTICAL) {
        clipRect.set(
                recyclerView.getPaddingLeft(),
                recyclerView.getPaddingTop(),
                recyclerView.getWidth() - recyclerView.getPaddingRight() - clipRect.right,
                recyclerView.getHeight() - recyclerView.getPaddingBottom());
    } else {
        clipRect.set(
                recyclerView.getPaddingLeft(),
                recyclerView.getPaddingTop(),
                recyclerView.getWidth() - recyclerView.getPaddingRight(),
                recyclerView.getHeight() - recyclerView.getPaddingBottom() - clipRect.bottom);
    }
}
 
Example 3
Project: redpacketui-open   File: HeaderRenderer.java   View Source Code Vote up 6 votes
/**
 * Initializes a clipping rect for the header based on the margins of the header and the padding of the
 * recycler.
 * FIXME: Currently right margin in VERTICAL orientation and bottom margin in HORIZONTAL
 * orientation are clipped so they look accurate, but the headers are not being drawn at the
 * correctly smaller width and height respectively.
 *
 * @param clipRect     {@link Rect} for clipping a provided header to the padding of a recycler view
 * @param recyclerView for which to provide a header
 * @param header       for clipping
 */
private void initClipRectForHeader(Rect clipRect, RecyclerView recyclerView, View header) {
    mDimensionCalculator.initMargins(clipRect, header);
    if (mOrientationProvider.getOrientation(recyclerView) == LinearLayout.VERTICAL) {
        clipRect.set(
                recyclerView.getPaddingLeft(),
                recyclerView.getPaddingTop(),
                recyclerView.getWidth() - recyclerView.getPaddingRight() - clipRect.right,
                recyclerView.getHeight() - recyclerView.getPaddingBottom());
    } else {
        clipRect.set(
                recyclerView.getPaddingLeft(),
                recyclerView.getPaddingTop(),
                recyclerView.getWidth() - recyclerView.getPaddingRight(),
                recyclerView.getHeight() - recyclerView.getPaddingBottom() - clipRect.bottom);
    }
}
 
Example 4
Project: CSipSimple   File: DialerCallBar.java   View Source Code Vote up 6 votes
public DialerCallBar(Context context, AttributeSet attrs, int style) {
    super(context, attrs);
    LayoutInflater inflater = LayoutInflater.from(context);
    inflater.inflate(R.layout.dialpad_additional_buttons, this, true);
    findViewById(R.id.dialVideoButton).setOnClickListener(this);
    findViewById(R.id.dialButton).setOnClickListener(this);
    findViewById(R.id.deleteButton).setOnClickListener(this);
    findViewById(R.id.deleteButton).setOnLongClickListener(this);
    
    if(getOrientation() == LinearLayout.VERTICAL) {
        LayoutParams lp;
        for(int i=0; i < getChildCount(); i++) {
            lp = (LayoutParams) getChildAt(i).getLayoutParams();
            int w = lp.width;
            lp.width = lp.height;
            lp.height = w;
            lp.gravity = Gravity.CENTER_HORIZONTAL;
            // Added for clarity but not necessary
            getChildAt(i).setLayoutParams(lp);
            
        }
    }
}
 
Example 5
Project: Hitalk   File: HeaderRenderer.java   View Source Code Vote up 6 votes
/**
 * Initializes a clipping rect for the header based on the margins of the header and the padding of the
 * recycler.
 * FIXME: Currently right margin in VERTICAL orientation and bottom margin in HORIZONTAL
 * orientation are clipped so they look accurate, but the headers are not being drawn at the
 * correctly smaller width and height respectively.
 *
 * @param clipRect {@link Rect} for clipping a provided header to the padding of a recycler view
 * @param recyclerView for which to provide a header
 * @param header       for clipping
 */
private void initClipRectForHeader(Rect clipRect, RecyclerView recyclerView, View header) {
  mDimensionCalculator.initMargins(clipRect, header);
  if (mOrientationProvider.getOrientation(recyclerView) == LinearLayout.VERTICAL) {
    clipRect.set(
        recyclerView.getPaddingLeft(),
        recyclerView.getPaddingTop(),
        recyclerView.getWidth() - recyclerView.getPaddingRight() - clipRect.right,
        recyclerView.getHeight() - recyclerView.getPaddingBottom());
  } else {
      clipRect.set(
        recyclerView.getPaddingLeft(),
        recyclerView.getPaddingTop(),
        recyclerView.getWidth() - recyclerView.getPaddingRight(),
        recyclerView.getHeight() - recyclerView.getPaddingBottom() - clipRect.bottom);
  }
}
 
Example 6
Project: PointSeekBar   File: PointSeekBar.java   View Source Code Vote up 6 votes
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
    float offset = event.getX();
    if (mOrientation == LinearLayout.VERTICAL) {
        offset = event.getY();
    }
    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
        case MotionEvent.ACTION_MOVE:
            setCurrentValueByLocation(offset);
            return true;
        case MotionEvent.ACTION_UP:
            onValueDone();
            break;
    }
    return super.dispatchTouchEvent(event);
}
 
Example 7
Project: CalendarChoose   File: MonthTimeActivity.java   View Source Code Vote up 5 votes
private void initView()
{
    startTime = (TextView) findViewById(R.id.plan_time_txt_start);
    stopTime = (TextView) findViewById(R.id.plan_time_txt_stop);

    recycler = (RecyclerView) findViewById(R.id.plan_time_calender);
    LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayout.VERTICAL, false);
    recycler.setLayoutManager(layoutManager);
}
 
Example 8
Project: RvAdapter   File: HeaderPositionCalculator.java   View Source Code Vote up 5 votes
/**
 * Determines if a view should have a sticky header.
 * The view has a sticky header if:
 * 1. It is the first element in the recycler view
 * 2. It has a valid ID associated to its position
 *
 * @param itemView    given by the RecyclerView
 * @param orientation of the Recyclerview
 * @param position    of the list item in question
 * @return True if the view should have a sticky header
 */
public boolean hasStickyHeader(View itemView, int orientation, int position) {
    int offset, margin;
    mDimensionCalculator.initMargins(mTempRect1, itemView);
    if (orientation == LinearLayout.VERTICAL) {
        offset = itemView.getTop();
        margin = mTempRect1.top;
    } else {
        offset = itemView.getLeft();
        margin = mTempRect1.left;
    }

    return offset <= margin && mAdapter.getHeaderId(position) >= 0;
}
 
Example 9
Project: redpacketui-open   File: HeaderPositionCalculator.java   View Source Code Vote up 5 votes
/**
 * Determines if a view should have a sticky header.
 * The view has a sticky header if:
 * 1. It is the first element in the recycler view
 * 2. It has a valid ID associated to its position
 *
 * @param itemView    given by the RecyclerView
 * @param orientation of the RecyclerView
 * @param position    of the list item in question
 * @return True if the view should have a sticky header
 */
boolean hasStickyHeader(View itemView, int orientation, int position) {
    int offset, margin;
    mDimensionCalculator.initMargins(mTempRect1, itemView);
    if (orientation == LinearLayout.VERTICAL) {
        offset = itemView.getTop();
        margin = mTempRect1.top;
    } else {
        offset = itemView.getLeft();
        margin = mTempRect1.left;
    }

    return offset <= margin && mAdapter.getHeaderId(position) >= 0;
}
 
Example 10
Project: MoeSampleApp   File: RepositoryActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_repo);
    mRecyclerView = (RecyclerView) findViewById(R.id.rv_repositories);
    mLayoutManager = new LinearLayoutManager(this);
    mRecyclerView.setLayoutManager(mLayoutManager);
    DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
            LinearLayout.VERTICAL);
    mRecyclerView.addItemDecoration(dividerItemDecoration);
    RepositoryPresenter repositoryPresenter = new RepositoryPresenter(this);
    repositoryPresenter.getRepositories(AndroidSchedulers.mainThread(), Schedulers.newThread());
}
 
Example 11
Project: Hitalk   File: HeaderPositionCalculator.java   View Source Code Vote up 5 votes
/**
 * Determines if a view should have a sticky header.
 * The view has a sticky header if:
 * 1. It is the first element in the recycler view
 * 2. It has a valid ID associated to its position
 *
 * @param itemView given by the RecyclerView
 * @param orientation of the Recyclerview
 * @param position of the list item in question
 * @return True if the view should have a sticky header
 */
public boolean hasStickyHeader(View itemView, int orientation, int position) {
  int offset, margin;
  mDimensionCalculator.initMargins(mTempRect1, itemView);
  if (orientation == LinearLayout.VERTICAL) {
    offset = itemView.getTop();
    margin = mTempRect1.top;
  } else {
    offset = itemView.getLeft();
    margin = mTempRect1.left;
  }

  return offset <= margin && mAdapter.getHeaderId(position) >= 0;
}
 
Example 12
Project: Widgets   File: ExpandTextView.java   View Source Code Vote up 5 votes
@Override
    public void setOrientation(int orientation) {
        if (LinearLayout.HORIZONTAL == orientation) {
//            throw new IllegalArgumentException("ExpandTextView only supports Vertical Orientation.");
            //强制使用垂直布局
            super.setOrientation(LinearLayout.VERTICAL);
        }
        super.setOrientation(orientation);
    }
 
Example 13
Project: RefreshWithAppBarLayout   File: PullToRefreshBase.java   View Source Code Vote up 5 votes
@Override
public void setOrientation(int orientation) {
    if (LinearLayout.VERTICAL != orientation) {
        throw new IllegalArgumentException("This class only supports VERTICAL orientation.");
    }

    // Only support vertical orientation
    super.setOrientation(orientation);
}
 
Example 14
Project: RLibrary   File: RViewPager.java   View Source Code Vote up 5 votes
public RViewPager(Context context, AttributeSet attrs) {
    super(context, attrs);
    if (mOrientation == LinearLayout.HORIZONTAL) {
        setPageTransformer(true, new FadeInOutPageTransformer());
    } else {
        setPageTransformer(true, new DefaultVerticalTransformer());
    }
    mGestureDetectorCompat = new GestureDetectorCompat(context, new GestureDetector.SimpleOnGestureListener() {

        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            if (mOnPagerEndListener != null &&
                    getAdapter() != null &&
                    getCurrentItem() == getAdapter().getCount() - 1) {
                if (mOrientation == LinearLayout.VERTICAL) {
                    if (velocityY < -1000) {
                        mOnPagerEndListener.onPagerEnd();
                    }
                } else {
                    if (velocityX < -1000) {
                        mOnPagerEndListener.onPagerEnd();
                    }
                }
            }
            return super.onFling(e1, e2, velocityX, velocityY);
        }
    });
}
 
Example 15
Project: RLibrary   File: RViewPager.java   View Source Code Vote up 5 votes
@Override
public boolean onTouchEvent(MotionEvent ev) {
    try {
        if (mOrientation == LinearLayout.VERTICAL) {
            return mGestureDetectorCompat.onTouchEvent(ev)
                    || super.onTouchEvent(swapTouchEvent(ev));
        }
        return mGestureDetectorCompat.onTouchEvent(ev)
                || super.onTouchEvent(ev);
    } catch (IllegalArgumentException ex) {
        ex.printStackTrace();
    }
    return false;
}
 
Example 16
Project: RLibrary   File: RViewPager.java   View Source Code Vote up 5 votes
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    try {
        if (mOrientation == LinearLayout.VERTICAL) {
            return super.onInterceptTouchEvent(swapTouchEvent(ev));
        }
        return super.onInterceptTouchEvent(ev);
    } catch (IllegalArgumentException ex) {
        ex.printStackTrace();
    }
    return false;
}
 
Example 17
Project: GitHub   File: RecyclerViewActivity1.java   View Source Code Vote up 4 votes
private void initListAdapterV() {
    LinearLayoutManager layoutManger = new LinearLayoutManager(this, LinearLayout.VERTICAL, false);
    mRv.setLayoutManager(layoutManger);
    mRv.setAdapter(mListAdapter);
}
 
Example 18
Project: Farmacias   File: ExpandableLinearLayout.java   View Source Code Vote up 4 votes
private boolean isVertical() {
    return getOrientation() == LinearLayout.VERTICAL;
}
 
Example 19
Project: PointSeekBar   File: PointSeekBar.java   View Source Code Vote up 4 votes
@SuppressLint("DrawAllocation")
@Override
protected void onDraw(Canvas canvas) {
    int width = getMeasuredWidth();
    int height = getMeasuredHeight();
    float halfSplit = (height + getPaddingTop() - getPaddingBottom()) * 1.0f / 2;
    if (mOrientation == LinearLayout.VERTICAL) {
        halfSplit =  (width + getPaddingLeft() - getPaddingRight()) * 1.0f / 2;
    }
    mBlockWidth = (width - getPaddingLeft() - getPaddingRight() - mBlockRadius * 2) * 1.0f / _max;
    if (mOrientation == LinearLayout.VERTICAL) {
        mBlockWidth = (height - getPaddingTop() - getPaddingBottom() - mBlockRadius * 2) * 1.0f / _max;
    }
    Path activePath = new Path();
    Path disabledPath = new Path();
    int left, top, right, bottom;
    if (mOrientation == LinearLayout.VERTICAL) {
        left = (int) (halfSplit - mProgressHeight / 2 + getPaddingLeft());
        top = (int) (mBlockRadius + getPaddingTop());
        right = (int) (halfSplit + mProgressHeight / 2 - getPaddingRight());
        bottom =  (int) (height - mBlockRadius - getPaddingBottom());
    }else {
        left = (int) (mBlockRadius + getPaddingLeft());
        top = (int) (halfSplit - mProgressHeight / 2 + getPaddingTop());
        right = (int) (width - mBlockRadius - getPaddingRight());
        bottom =  (int) (halfSplit + mProgressHeight / 2 - getPaddingBottom());
    }
    if (mOrientation == LinearLayout.VERTICAL) {
        activePath.addRect(left, top, right, top +  +  mBlockWidth * _progress,  Path.Direction.CW);
        disabledPath.addRect(left, top  +  mBlockWidth * _progress, right, bottom, Path.Direction.CW);
    }else {
        activePath.addRect(left, top, left +  mBlockWidth * _progress, bottom,  Path.Direction.CW);
        disabledPath.addRect(left +  mBlockWidth * _progress, top, right, bottom, Path.Direction.CW);
    }
    float center = 0;
    float offset = 0;
    for (int i = 0; i <= _max; i++) {
        offset = mOrientation == LinearLayout.VERTICAL ? top + i * mBlockWidth :  left + i * mBlockWidth;
        if (i < _progress) {
            if (mOrientation == LinearLayout.VERTICAL) {
                activePath.addCircle(halfSplit, offset, mSmallRadius, Path.Direction.CW);
            }else {
                activePath.addCircle(offset, halfSplit, mSmallRadius, Path.Direction.CW);
            }
        }else if (i > _progress) {
            if (mOrientation == LinearLayout.VERTICAL) {
                disabledPath.addCircle(halfSplit, offset, mSmallRadius, Path.Direction.CW);
            }else {
                disabledPath.addCircle(offset, halfSplit, mSmallRadius, Path.Direction.CW);
            }
        }else {
            center = offset;
        }
    }
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setColor(mProgressFullColor);
    canvas.drawPath(activePath, mPaint);
    mPaint.setColor(mProgressEmptyColor);
    canvas.drawPath(disabledPath, mPaint);
    //cur progress
    mPaint.setColor(mBlockBorderLineColor);
    if (mOrientation == LinearLayout.VERTICAL) {
        canvas.drawCircle(halfSplit, center, mBlockRadius, mPaint);
    }else {
        canvas.drawCircle(center, halfSplit, mBlockRadius, mPaint);
    }
    mPaint.setColor(mBlockBorderFillColor);
    if (mOrientation == LinearLayout.VERTICAL) {
        canvas.drawCircle(halfSplit, center, mBlockRadius - mBlockBorderWidth, mPaint);
    }else {
        canvas.drawCircle(center, halfSplit, mBlockRadius - mBlockBorderWidth, mPaint);
    }
}