Java Code Examples for android.widget.LinearLayout.setOrientation()

The following are Jave code examples for showing how to use setOrientation() 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: airgram   File: ScrollSlidingTabStrip.java   View Source Code Vote up 6 votes
public ScrollSlidingTabStrip(Context context) {
    super(context);

    setFillViewport(true);
    setWillNotDraw(false);

    setHorizontalScrollBarEnabled(false);
    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    addView(tabsContainer);

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(AndroidUtilities.dp(52), LayoutHelper.MATCH_PARENT);
}
 
Example 2
Project: sctalk   File: YayaEmoGridView.java   View Source Code Vote up 6 votes
private void initViewPage() {
    setOrientation(VERTICAL);
    _viewPager = new ViewPager(_context);
    _llDot = new LinearLayout(_context);

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT,
            CommonUtil.getDefaultPannelHeight(_context));
    params.gravity=Gravity.BOTTOM;
    _viewPager.setLayoutParams(params);
    _llDot.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT));
    _llDot.setGravity(Gravity.CENTER);
    _llDot.setOrientation(HORIZONTAL);
    addView(_viewPager);
    addView(_llDot);
}
 
Example 3
Project: FloatingApps   File: MenuItem.java   View Source Code Vote up 6 votes
public LinearLayout show() {
    final LinearLayout mainLayout = new LinearLayout(this.ctx);
    final MenuItem that = this;
    this.articleView.setOnTouchListener(new OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            if(event.getAction() == MotionEvent.ACTION_DOWN) {
                mainLayout.setBackgroundColor(Color.parseColor("#EEEEEE"));
            }
            if(event.getAction() == MotionEvent.ACTION_UP) {
                mainLayout.setBackgroundColor(Color.WHITE);
                if(event.getX() > 0 && event.getY() > 0 && event.getX() < Utils.dip2px(that.ctx, 200) && event.getY() < Utils.dip2px(that.ctx, 25)) {
                    if(that.listener != null) that.listener.onClick(v);
                }
            }
            return true;
        }
    });
    mainLayout.setOrientation(0);
    mainLayout.setLayoutParams(new LinearLayout.LayoutParams(Utils.dip2px(this.ctx, 200), Utils.dip2px(this.ctx, 25)));
    mainLayout.addView(this.iconView);
    mainLayout.addView(this.articleView);
    return mainLayout;
}
 
Example 4
Project: SScheduleView-Android   File: SScheduleView.java   View Source Code Vote up 6 votes
/**
     * 绘制其他行的第一列,即课程节数
     *
     * @param scrollContentView
     */
    private void drawOtherRowFirstCol(LinearLayout scrollContentView) {
        sideView = new LinearLayout(getContext());
        LinearLayout.LayoutParams sideViewLP = new LinearLayout.LayoutParams(firstColumnWidth, android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
        sideView.setLayoutParams(sideViewLP);
        sideView.setOrientation(LinearLayout.VERTICAL);
        scrollContentView.addView(sideView);

        for (int i = 0; i < showJiesNum; i++) {
            View jieciTV=mAdapter.getPeriodView(i+1+"");
//            TextView jieciTV = new TextView(getContext());
            LinearLayout.LayoutParams jieciTVLP = new LinearLayout.LayoutParams(firstColumnWidth, notFirstEveryRowHeight);
            jieciTV.setLayoutParams(jieciTVLP);
            jieciTV.setBackgroundResource(R.drawable.side_view_back);
//            jieciTV.setText("" + (i + 1));
//            jieciTV.setGravity(Gravity.CENTER);
//            jieciTV.setTextColor(Color.GRAY);
            sideView.addView(jieciTV);
        }
    }
 
Example 5
Project: SwipeMenuAndPullToRefresh   File: SMExpandView.java   View Source Code Vote up 6 votes
private void addItem(SwipeMenuItem item, int id) {
	LayoutParams params = new LayoutParams(item.getWidth(),
			LayoutParams.MATCH_PARENT);
	LinearLayout parent = new LinearLayout(getContext());
	parent.setId(id);
	parent.setGravity(Gravity.CENTER);
	parent.setOrientation(LinearLayout.VERTICAL);
	parent.setLayoutParams(params);
	parent.setBackgroundDrawable(item.getBackground());
	parent.setOnClickListener(this);

	addView(parent);

	if (item.getIcon() != null) {
		parent.addView(createIcon(item));
	}
	if (!TextUtils.isEmpty(item.getTitle())) {
		parent.addView(createTitle(item));
	}

}
 
Example 6
Project: YCCustomText   File: HyperTextView.java   View Source Code Vote up 6 votes
/**
 * 初始化
 */
private void init(Context context) {
    inflater = LayoutInflater.from(context);
    // 1. 初始化allLayout
    allLayout = new LinearLayout(context);
    allLayout.setOrientation(LinearLayout.VERTICAL);
    //allLayout.setBackgroundColor(Color.WHITE);//去掉背景
    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    allLayout.setPadding(50, 15, 50, 15);//设置间距,防止生成图片时文字太靠边
    addView(allLayout, layoutParams);

    LinearLayout.LayoutParams firstEditParam = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    //editNormalPadding = dip2px(EDIT_PADDING);
    TextView firstText = createTextView("没有内容", dip2px(context, EDIT_PADDING));
    allLayout.addView(firstText, firstEditParam);
}
 
Example 7
Project: Unofficial-Ups   File: WeekDatePicker.java   View Source Code Vote up 5 votes
private void initWithSelected(Context context, int selected){

        //Add line behind
        if(mNumberOfDays > 0){
            LayoutParams lineParams =new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,4);
            mLine= new View(context);
            mLine.setLayoutParams(lineParams);
            mLine.setBackgroundColor(ContextCompat.getColor(context,R.color.week_picker_inactive));
            addView(mLine,lineParams);
        }

        //Create container layout
        mBulletsLayout = new LinearLayout(context);
        mBulletsLayout.setOrientation(LinearLayout.HORIZONTAL);
        //Setup size
        LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT,getContext().getResources().getDimensionPixelSize(R.dimen.week_picker_height));
        mBulletsLayout.setLayoutParams(params);
        //Add layout to root view
        addView(mBulletsLayout);

        //Create items for each day
        Calendar c = Calendar.getInstance();
        // Set the calendar to monday of the current week
        c.setFirstDayOfWeek(Calendar.MONDAY);
        c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
        setDatesStartingIn(context,c.getTime(),new Date());

    }
 
Example 8
Project: GitHub   File: DropDownMenu.java   View Source Code Vote up 5 votes
public DropDownMenu(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    setOrientation(VERTICAL);

    //为DropDownMenu添加自定义属性
    int menuBackgroundColor = 0xffffffff;
    int underlineColor = 0xffcccccc;
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DropDownMenu);
    underlineColor = a.getColor(R.styleable.DropDownMenu_ddunderlineColor, underlineColor);
    dividerColor = a.getColor(R.styleable.DropDownMenu_dddividerColor, dividerColor);
    textSelectedColor = a.getColor(R.styleable.DropDownMenu_ddtextSelectedColor, textSelectedColor);
    textUnselectedColor = a.getColor(R.styleable.DropDownMenu_ddtextUnselectedColor, textUnselectedColor);
    menuBackgroundColor = a.getColor(R.styleable.DropDownMenu_ddmenuBackgroundColor, menuBackgroundColor);
    maskColor = a.getColor(R.styleable.DropDownMenu_ddmaskColor, maskColor);
    menuTextSize = a.getDimensionPixelSize(R.styleable.DropDownMenu_ddmenuTextSize, menuTextSize);
    menuSelectedIcon = a.getResourceId(R.styleable.DropDownMenu_ddmenuSelectedIcon, menuSelectedIcon);
    menuUnselectedIcon = a.getResourceId(R.styleable.DropDownMenu_ddmenuUnselectedIcon, menuUnselectedIcon);
    a.recycle();

    //初始化tabMenuView并添加到tabMenuView
    tabMenuView = new LinearLayout(context);
    LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    tabMenuView.setOrientation(HORIZONTAL);
    tabMenuView.setBackgroundColor(menuBackgroundColor);
    tabMenuView.setLayoutParams(params);
    addView(tabMenuView, 0);

    //为tabMenuView添加下划线
    View underLine = new View(getContext());
    underLine.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpTpPx(1.0f)));
    underLine.setBackgroundColor(underlineColor);
    addView(underLine, 1);

    //初始化containerView并将其添加到DropDownMenu
    containerView = new FrameLayout(context);
    containerView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
    addView(containerView, 2);

}
 
Example 9
Project: LoRaWAN-Smart-Parking   File: CordovaChromeClient.java   View Source Code Vote up 5 votes
@Override
/**
 * Ask the host application for a custom progress view to show while
 * a <video> is loading.
 * @return View The progress view.
 */
public View getVideoLoadingProgressView() {

    if (mVideoProgressView == null) {            
        // Create a new Loading view programmatically.
        
        // create the linear layout
        LinearLayout layout = new LinearLayout(this.appView.getContext());
        layout.setOrientation(LinearLayout.VERTICAL);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        layout.setLayoutParams(layoutParams);
        // the proress bar
        ProgressBar bar = new ProgressBar(this.appView.getContext());
        LinearLayout.LayoutParams barLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        barLayoutParams.gravity = Gravity.CENTER;
        bar.setLayoutParams(barLayoutParams);   
        layout.addView(bar);
        
        mVideoProgressView = layout;
    }
return mVideoProgressView; 
}
 
Example 10
Project: cniao5   File: EditPagePort.java   View Source Code Vote up 5 votes
public void onCreate() {
	super.onCreate();

	int screenHeight = ResHelper.getScreenHeight(activity);
	float ratio = ((float) screenHeight) / DESIGN_SCREEN_HEIGHT;

	maxBodyHeight = 0;

	llPage = new LinearLayout(activity);
	llPage.setOrientation(LinearLayout.VERTICAL);
	activity.setContentView(llPage);

	rlTitle = new RelativeLayout(activity);
	rlTitle.setBackgroundColor(0xffe6e9ec);
	int titleHeight = (int) (DESIGN_TITLE_HEIGHT * ratio);

	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, titleHeight);
	llPage.addView(rlTitle, lp);
	initTitle(rlTitle, ratio);

	RelativeLayout rlBody = new RelativeLayout(activity);
	rlBody.setBackgroundColor(0xffffffff);
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	llPage.addView(rlBody, lp);
	initBody(rlBody, ratio);

	LinearLayout llShadow = new LinearLayout(activity);
	llShadow.setOrientation(LinearLayout.VERTICAL);
	rlBody.addView(llShadow, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	initShadow(llShadow, ratio);

	llBottom = new LinearLayout(activity);
	llBottom.setOrientation(LinearLayout.VERTICAL);
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	llPage.addView(llBottom, lp);
	initBottom(llBottom, ratio);
}
 
Example 11
Project: yyox   File: EditPageLand.java   View Source Code Vote up 5 votes
private void initBody(RelativeLayout rlBody, float ratio) {
	svContent = new ScrollView(activity);
	rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	LinearLayout llContent = new LinearLayout(activity);
	llContent.setOrientation(LinearLayout.HORIZONTAL);
	svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	etContent = new EditText(activity);
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	etContent.setPadding(padding, padding, padding, padding);
	etContent.setBackgroundDrawable(null);
	etContent.setTextColor(0xff3b3b3b);
	etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
	etContent.setText(sp.getText());
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT);
	lp.weight = 1;
	llContent.addView(etContent, lp);
	etContent.addTextChangedListener(this);

	rlThumb = new RelativeLayout(activity);
	rlThumb.setBackgroundColor(0xff313131);
	int	thumbWidth = (int) (DESIGN_THUMB_HEIGHT_L * ratio);
	int	xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT_L * ratio);
	lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth);
	lp.rightMargin = lp.bottomMargin = lp.topMargin = padding;
	llContent.addView(rlThumb, lp);

	aivThumb = new AsyncImageView(activity) {
		public void onImageGot(String url, Bitmap bm) {
			thumb = bm;
			super.onImageGot(url, bm);
		}
	};
	aivThumb.setScaleToCropCenter(true);
	RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth);
	rlThumb.addView(aivThumb, rllp);
	aivThumb.setOnClickListener(this);
	initThumb(aivThumb);

	xvRemove = new XView(activity);
	xvRemove.setRatio(ratio);
	rllp = new RelativeLayout.LayoutParams(xWidth, xWidth);
	rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
	rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	rlThumb.addView(xvRemove, rllp);
	xvRemove.setOnClickListener(this);
}
 
Example 12
Project: GitHub   File: BGARefreshLayout.java   View Source Code Vote up 5 votes
/**
 * 初始化整个头部控件
 */
private void initWholeHeaderView() {
    mWholeHeaderView = new LinearLayout(getContext());
    mWholeHeaderView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    mWholeHeaderView.setOrientation(LinearLayout.VERTICAL);
    addView(mWholeHeaderView);
}
 
Example 13
Project: DinningShare   File: SystemWebChromeClient.java   View Source Code Vote up 5 votes
@Override
/**
 * Ask the host application for a custom progress view to show while
 * a <video> is loading.
 * @return View The progress view.
 */
public View getVideoLoadingProgressView() {

    if (mVideoProgressView == null) {
        // Create a new Loading view programmatically.

        // create the linear layout
        LinearLayout layout = new LinearLayout(parentEngine.getView().getContext());
        layout.setOrientation(LinearLayout.VERTICAL);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        layout.setLayoutParams(layoutParams);
        // the proress bar
        ProgressBar bar = new ProgressBar(parentEngine.getView().getContext());
        LinearLayout.LayoutParams barLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        barLayoutParams.gravity = Gravity.CENTER;
        bar.setLayoutParams(barLayoutParams);
        layout.addView(bar);

        mVideoProgressView = layout;
    }
return mVideoProgressView;
}
 
Example 14
Project: AndroidBasicLibs   File: DrawerToast.java   View Source Code Vote up 5 votes
/**
 * 初始化视图控件
 */
private void initView() {
    mHandler = new Handler(mContext.getMainLooper());

    lp_WW = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    lp_MM = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);

    DisplayMetrics mDisplayMetrics = mContext.getResources().getDisplayMetrics();
    screenWidth = mDisplayMetrics.widthPixels;
    screenHeight = mDisplayMetrics.heightPixels;

    mTopView = new LinearLayout(mContext);
    mTopView.setLayoutParams(lp_MM);
    mTopView.setOrientation(LinearLayout.VERTICAL);
    mTopView.setGravity(Gravity.CENTER);

    mTopView2 = new LinearLayout(mContext);

    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(screenWidth, screenHeight);
    mTopView2.setLayoutParams(params);
    mTopView2.setOrientation(LinearLayout.VERTICAL);
    mTopView2.setGravity(Gravity.BOTTOM);

    mView = new LinearLayout(mContext);
    mView.setLayoutParams(lp_MM);
    mView.setOrientation(LinearLayout.VERTICAL);
    mView.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM);

    View gapView = new View(mContext);
    gapView.setLayoutParams(new LinearLayout.LayoutParams(screenWidth, screenHeight / 4));
    mView.addView(gapView);

    mTopView.addView(mTopView2);
    mTopView2.addView(mView);

    resetDefaultBackgroundAndTextColor();
}
 
Example 15
Project: Mybilibili   File: EditPagePort.java   View Source Code Vote up 4 votes
private void initBody(RelativeLayout rlBody, float ratio) {
	svContent = new ScrollView(activity);
	rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	LinearLayout llContent = new LinearLayout(activity);
	llContent.setOrientation(LinearLayout.VERTICAL);
	svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	etContent = new EditText(activity);
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	etContent.setPadding(padding, padding, padding, padding);
	etContent.setBackgroundDrawable(null);
	etContent.setTextColor(0xff3b3b3b);
	etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
	etContent.setText(sp.getText());
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	llContent.addView(etContent, lp);
	etContent.addTextChangedListener(this);

	rlThumb = new RelativeLayout(activity);
	rlThumb.setBackgroundColor(0xff313131);
	int	thumbWidth = (int) (DESIGN_THUMB_HEIGHT * ratio);
	int	xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT * ratio);
	lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth);
	lp.leftMargin = lp.rightMargin = lp.bottomMargin = lp.topMargin = padding;
	llContent.addView(rlThumb, lp);

	aivThumb = new AsyncImageView(activity) {
		public void onImageGot(String url, Bitmap bm) {
			thumb = bm;
			super.onImageGot(url, bm);
		}
	};
	aivThumb.setScaleToCropCenter(true);
	RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth);
	rlThumb.addView(aivThumb, rllp);
	aivThumb.setOnClickListener(this);
	initThumb(aivThumb);

	xvRemove = new XView(activity);
	xvRemove.setRatio(ratio);
	rllp = new RelativeLayout.LayoutParams(xWidth, xWidth);
	rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
	rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	rlThumb.addView(xvRemove, rllp);
	xvRemove.setOnClickListener(this);
}
 
Example 16
Project: TextEmoji   File: EditPageLand.java   View Source Code Vote up 4 votes
private void initBody(RelativeLayout rlBody, float ratio) {
	svContent = new ScrollView(activity);
	rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	LinearLayout llContent = new LinearLayout(activity);
	llContent.setOrientation(LinearLayout.HORIZONTAL);
	svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	etContent = new EditText(activity);
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	etContent.setPadding(padding, padding, padding, padding);
	etContent.setBackgroundDrawable(null);
	etContent.setTextColor(0xff3b3b3b);
	etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
	etContent.setText(sp.getText());
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT);
	lp.weight = 1;
	llContent.addView(etContent, lp);
	etContent.addTextChangedListener(this);

	rlThumb = new RelativeLayout(activity);
	rlThumb.setBackgroundColor(0xff313131);
	int	thumbWidth = (int) (DESIGN_THUMB_HEIGHT_L * ratio);
	int	xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT_L * ratio);
	lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth);
	lp.rightMargin = lp.bottomMargin = lp.topMargin = padding;
	llContent.addView(rlThumb, lp);

	aivThumb = new AsyncImageView(activity) {
		public void onImageGot(String url, Bitmap bm) {
			thumb = bm;
			super.onImageGot(url, bm);
		}
	};
	aivThumb.setScaleToCropCenter(true);
	RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth);
	rlThumb.addView(aivThumb, rllp);
	aivThumb.setOnClickListener(this);
	initThumb(aivThumb);

	xvRemove = new XView(activity);
	xvRemove.setRatio(ratio);
	rllp = new RelativeLayout.LayoutParams(xWidth, xWidth);
	rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
	rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	rlThumb.addView(xvRemove, rllp);
	xvRemove.setOnClickListener(this);
}
 
Example 17
Project: KUtils-master   File: BGABanner.java   View Source Code Vote up 4 votes
private void initView(Context context) {
    RelativeLayout pointContainerRl = new RelativeLayout(context);
    if (Build.VERSION.SDK_INT >= 16) {
        pointContainerRl.setBackground(mPointContainerBackgroundDrawable);
    } else {
        pointContainerRl.setBackgroundDrawable(mPointContainerBackgroundDrawable);
    }
    pointContainerRl.setPadding(mPointContainerLeftRightPadding, mPointTopBottomMargin, mPointContainerLeftRightPadding, mPointTopBottomMargin);
    LayoutParams pointContainerLp = new LayoutParams(RMP, RWC);
    // 处理圆点在顶部还是底部
    if ((mPointGravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.TOP) {
        pointContainerLp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    } else {
        pointContainerLp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    }
    addView(pointContainerRl, pointContainerLp);


    LayoutParams indicatorLp = new LayoutParams(RWC, RWC);
    indicatorLp.addRule(CENTER_VERTICAL);
    if (mIsNumberIndicator) {
        mNumberIndicatorTv = new TextView(context);
        mNumberIndicatorTv.setId(R.id.banner_indicatorId);
        mNumberIndicatorTv.setGravity(Gravity.CENTER_VERTICAL);
        mNumberIndicatorTv.setSingleLine(true);
        mNumberIndicatorTv.setEllipsize(TextUtils.TruncateAt.END);
        mNumberIndicatorTv.setTextColor(mNumberIndicatorTextColor);
        mNumberIndicatorTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mNumberIndicatorTextSize);
        mNumberIndicatorTv.setVisibility(View.INVISIBLE);
        if (mNumberIndicatorBackground != null) {
            if (Build.VERSION.SDK_INT >= 16) {
                mNumberIndicatorTv.setBackground(mNumberIndicatorBackground);
            } else {
                mNumberIndicatorTv.setBackgroundDrawable(mNumberIndicatorBackground);
            }
        }
        pointContainerRl.addView(mNumberIndicatorTv, indicatorLp);
    } else {
        mPointRealContainerLl = new LinearLayout(context);
        mPointRealContainerLl.setId(R.id.banner_indicatorId);
        mPointRealContainerLl.setOrientation(LinearLayout.HORIZONTAL);
        mPointRealContainerLl.setGravity(Gravity.CENTER_VERTICAL);
        pointContainerRl.addView(mPointRealContainerLl, indicatorLp);
    }

    LayoutParams tipLp = new LayoutParams(RMP, RWC);
    tipLp.addRule(CENTER_VERTICAL);
    mTipTv = new TextView(context);
    mTipTv.setGravity(Gravity.CENTER_VERTICAL);
    mTipTv.setSingleLine(true);
    mTipTv.setEllipsize(TextUtils.TruncateAt.END);
    mTipTv.setTextColor(mTipTextColor);
    mTipTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTipTextSize);
    pointContainerRl.addView(mTipTv, tipLp);

    int horizontalGravity = mPointGravity & Gravity.HORIZONTAL_GRAVITY_MASK;
    // 处理圆点在左边、右边还是水平居中
    if (horizontalGravity == Gravity.LEFT) {
        indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        tipLp.addRule(RelativeLayout.RIGHT_OF, R.id.banner_indicatorId);
        mTipTv.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
    } else if (horizontalGravity == Gravity.RIGHT) {
        indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        tipLp.addRule(RelativeLayout.LEFT_OF, R.id.banner_indicatorId);
    } else {
        indicatorLp.addRule(RelativeLayout.CENTER_HORIZONTAL);
        tipLp.addRule(RelativeLayout.LEFT_OF, R.id.banner_indicatorId);
    }

    showPlaceholder();
}
 
Example 18
Project: LQRWeChat   File: PlatformPage.java   View Source Code Vote up 4 votes
public void onCreate() {
	activity.getWindow().setBackgroundDrawable(new ColorDrawable(0x4c000000));
	initAnims();

	LinearLayout llPage = new LinearLayout(activity);
	llPage.setOrientation(LinearLayout.VERTICAL);
	activity.setContentView(llPage);

	TextView vTop = new TextView(activity);
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lp.weight = 1;
	vTop.setOnClickListener(new OnClickListener() {
		public void onClick(View v) {
			finish();
		}
	});
	llPage.addView(vTop, lp);

	llPanel = new LinearLayout(activity);
	llPanel.setOrientation(LinearLayout.VERTICAL);
	lp = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	llPanel.setAnimation(animShow);
	llPage.addView(llPanel, lp);

	MobViewPager mvp = new MobViewPager(activity);
	ArrayList<Object> cells = collectCells();
	PlatformPageAdapter adapter = newAdapter(cells);
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, adapter.getPanelHeight());
	llPanel.addView(mvp, lp);

	IndicatorView vInd = new IndicatorView(activity);
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, adapter.getBottomHeight());
	llPanel.addView(vInd, lp);

	vInd.setScreenCount(adapter.getCount());
	vInd.onScreenChange(0, 0);
	adapter.setIndicator(vInd);
	mvp.setAdapter(adapter);
}
 
Example 19
Project: FloatingApps   File: SettingActivity.java   View Source Code Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.setting);
    
    ctx = getApplicationContext();
    wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    WIDTH = wm.getDefaultDisplay().getWidth();
    HEIGHT = wm.getDefaultDisplay().getHeight();
    DP = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, ctx.getResources().getDisplayMetrics());
    
    /*---main layout---*/
    main = new LinearLayout(ctx);
    main.setOrientation(1);
    main.setPadding(15 * DP, 10 * DP, 15 * DP, 5 * DP);
    
    /*---head color setting---*/
    LinearLayout head = new LinearLayout(ctx);
    head.setOrientation(0);
    head.setPadding(15 * DP, 5 * DP, 15 * DP, 5 * DP);
    
    TextView tv = new TextView(ctx);
    tv.setText("Head 색상 바꾸기");
    tv.setTextSize(20);
    tv.setTextColor(Color.BLACK);
    head.addView(tv, WIDTH - 95 * DP, 35 * DP);
    
    Button colorPick = new Button(ctx);
    colorPick.setText("");
    GradientDrawable gradient = new GradientDrawable();
    gradient.setStroke(3 * DP, Color.GRAY);
    gradient.setCornerRadius(500 * DP);
    gradient.setColor(Color.rgb(90, 110, 255));
    colorPick.setBackgroundDrawable(gradient);
    head.addView(colorPick, 35 * DP, 35 * DP);
    
    main.addView(head);
    main.addView(line(Color.GRAY));
    
    setContentView(main);
}
 
Example 20
Project: POCenter   File: FriendListPage.java   View Source Code Vote up 4 votes
public void onCreate() {
	activity.getWindow().setBackgroundDrawable(new ColorDrawable(0xfff3f3f3));

	llPage = new LinearLayout(activity);
	llPage.setOrientation(LinearLayout.VERTICAL);
	activity.setContentView(llPage);

	rlTitle = new RelativeLayout(activity);
	float ratio = getRatio();
	int titleHeight = (int) (getDesignTitleHeight() * ratio);
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, titleHeight);
	llPage.addView(rlTitle, lp);
	initTitle(rlTitle, ratio);

	View line = new View(activity);
	LinearLayout.LayoutParams lpline = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, (int) (ratio < 1 ? 1 : ratio));
	line.setBackgroundColor(0xffdad9d9);
	llPage.addView(line, lpline);

	FrameLayout flPage = new FrameLayout(getContext());
	LinearLayout.LayoutParams lpFl = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lpFl.weight = 1;
	flPage.setLayoutParams(lpFl);
	llPage.addView(flPage);

	// 关注(或朋友)列表
	PullToRequestView followList = new PullToRequestView(getContext());
	FrameLayout.LayoutParams lpLv = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	followList.setLayoutParams(lpLv);
	flPage.addView(followList);

	adapter = new FriendAdapter(this, followList);
	adapter.setPlatform(platform);
	adapter.setRatio(ratio);
	adapter.setOnItemClickListener(this);
	followList.setAdapter(adapter);

	// 请求数据
	followList.performPullingDown(true);
}