Java Code Examples for android.widget.LinearLayout.MarginLayoutParams

The following are Jave code examples for showing how to use MarginLayoutParams 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: Carousel   File: CarouselView.java   View Source Code Vote up 6 votes
/**
 * 添加底部Indicator点
 */
private void addIndicator() {
    llIndicator.removeAllViews();
    indicatorViews.clear();
    for (int i = 0; i < carouselPageAdapter.getCount(); i++) {
        View indicatorView = new View(context);
        indicatorView.setBackgroundResource(i == 0 ? indicatorSelected : indicatorUnselected);
        llIndicator.addView(indicatorView);
        LinearLayout.MarginLayoutParams params = (LinearLayout.MarginLayoutParams) indicatorView.getLayoutParams();
        if (i == 0 && indicatorSelectedWidth > 0 && indicatorSelectedHeight > 0) {
            params.width = indicatorSelectedWidth;
            params.height = indicatorSelectedHeight;
        } else if (i > 0 && indicatorUnSelectedWidth > 0 && indicatorUnSelectedHeight > 0) {
            params.width = indicatorUnSelectedWidth;
            params.height = indicatorUnSelectedHeight;
        } else {
            params.width = indicatorWidth;
            params.height = indicatorHeight;
        }
        params.leftMargin = indicatorPadding / 2;
        params.rightMargin = indicatorPadding / 2;
        indicatorView.setLayoutParams(params);
        indicatorViews.add(indicatorView);
    }
}