Java Code Examples for android.view.ViewGroup.LayoutParams#MATCH_PARENT

The following examples show how to use android.view.ViewGroup.LayoutParams#MATCH_PARENT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WXSlider.java    From weex with Apache License 2.0 6 votes vote down vote up
@Override
protected void initView() {
  mRoot = new FrameLayout(mContext);
  // init view pager
  FrameLayout.LayoutParams pagerParams = new FrameLayout.LayoutParams(
      LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
  mViewPager = new WXCircleViewPager(mContext);
  mViewPager.setLayoutParams(pagerParams);

  // init adapter
  mAdapter = new WXCirclePageAdapter();
  mViewPager.setAdapter(mAdapter);
  // add to parent
  mRoot.addView(mViewPager);
  mHost = mRoot;
  mViewPager.setOnPageChangeListener(this);
  registerActivityStateListener();
}
 
Example 2
Source File: EditPagePort.java    From Social with Apache License 2.0 5 votes vote down vote up
public void onCreate() {
	super.onCreate();

	int screenHeight = R.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 3
Source File: EditPageLand.java    From Social with Apache License 2.0 5 votes vote down vote up
private void initBottom(LinearLayout llBottom, float ratio) {
	LinearLayout llAt = new LinearLayout(activity);
	llAt.setPadding(0, 0, 0, 5);
	llAt.setBackgroundColor(0xffffffff);
	int bottomHeight = (int) (DESIGN_BOTTOM_HEIGHT * ratio);
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, bottomHeight);
	llBottom.addView(llAt, lp);

	tvAt = new TextView(activity);
	tvAt.setTextColor(0xff3b3b3b);
	tvAt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
	tvAt.setGravity(Gravity.BOTTOM);
	tvAt.setText("@");
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	tvAt.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	llAt.addView(tvAt, lp);
	tvAt.setOnClickListener(this);
	if (isShowAtUserLayout(platform.getName())) {
		tvAt.setVisibility(View.VISIBLE);
	} else {
		tvAt.setVisibility(View.INVISIBLE);
	}

	tvTextCouter = new TextView(activity);
	tvTextCouter.setTextColor(0xff3b3b3b);
	tvTextCouter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvTextCouter.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
	onTextChanged(etContent.getText(), 0, 0, 0);
	tvTextCouter.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.weight = 1;
	llAt.addView(tvTextCouter, lp);

	View v = new View(activity);
	v.setBackgroundColor(0xffcccccc);
	int px_1 = ratio > 1 ? ((int) ratio) : 1;
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, px_1);
	llBottom.addView(v, lp);
}
 
Example 4
Source File: BaseDialog.java    From Ticket-Analysis with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    LayoutParams clp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    LayoutInflater layoutInflater = LayoutInflater.from(getContext());

    View content = getContentView(layoutInflater);
    initView(content);
    View layout = getBaseDialogView(layoutInflater);
    AutoUtils.autoSize(layout); //适配

    layout.findViewById(R.id.dialog_top).setOnClickListener(this);
    layout.findViewById(R.id.dialog_bottom).setOnClickListener(this);

    LinearLayout contentLayout = (LinearLayout) layout.findViewById(R.id.dialog_content);
    contentLayout.addView(content, clp);

    setContentView(layout, clp);
    setCancelable(true);
    setCanceledOnTouchOutside(true);


    WindowManager.LayoutParams lParams = getWindow().getAttributes();
    lParams.gravity = Gravity.CENTER;
    lParams.width = LayoutParams.MATCH_PARENT;
    lParams.height = LayoutParams.MATCH_PARENT;
    lParams.alpha = 1.0f;
    lParams.dimAmount = 0.0f;
    getWindow().setWindowAnimations(R.style.dialogWindowAnim);
    getWindow().setAttributes(lParams);
}
 
Example 5
Source File: BaseActivity.java    From AndroidTranslucentUI with Apache License 2.0 5 votes vote down vote up
protected void setContentLayout(int viewId) {
	LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	contentView = inflater.inflate(viewId, null);
	LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,
			LayoutParams.MATCH_PARENT);
	contentView.setLayoutParams(layoutParams);
	if (null != rootContent) {
		rootContent.addView(contentView);
	}
}
 
Example 6
Source File: MainActivity.java    From slidingtabs with GNU General Public License v2.0 5 votes vote down vote up
public MySlidingDrawer createTab(final int index) {
	RelativeLayout rootLayout = (RelativeLayout) findViewById(R.id.root);
	LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	final MySlidingDrawer slidingDrawer;
	if (index % 2 == 0) {
		slidingDrawer = (MySlidingDrawer) inflater.inflate(
				R.layout.tab_left, null);
	} else {
		slidingDrawer = (MySlidingDrawer) inflater.inflate(
				R.layout.tab_right, null);
	}

	RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
	rootLayout.addView(slidingDrawer, params);
	mTabs.add(slidingDrawer);

	slidingDrawer
			.setOnDrawerScrollListener(new MySlidingDrawer.OnDrawerScrollListener() {
				@Override
				public void onScrollStarted() {
					for (MySlidingDrawer tab : mTabs) {
						if (!slidingDrawer.equals(tab) && tab.isOpened())
							tab.close();
					}
				}

				@Override
				public void onScrollEnded() {
				}
			});

	slidingDrawer.getContent().setClickable(true);
	return slidingDrawer;
}
 
Example 7
Source File: QuickReturnHeaderHelper.java    From QuickReturnHeader with Apache License 2.0 5 votes vote down vote up
private void createScrollView() {
    root = (FrameLayout) inflater.inflate(R.layout.qrh__scrollview_container, null);

    NotifyingScrollView scrollView = (NotifyingScrollView) root.findViewById(R.id.rqh__scroll_view);
    scrollView.setOnScrollChangedListener(mOnScrollChangedListener);

    root.addView(realHeader, realHeaderLayoutParams);

    mContentContainer = (ViewGroup) root.findViewById(R.id.rqh__container);
    mContentContainer.addView(content);

    dummyHeader = mContentContainer.findViewById(R.id.rqh__content_top_margin);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, headerHeight);
    dummyHeader.setLayoutParams(params);
}
 
Example 8
Source File: TrafficMeterAbstract.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
protected TrafficMeterAbstract(Context context) {
    super(context);

    LinearLayout.LayoutParams lParams = new LinearLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    mMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2,
            context.getResources().getDisplayMetrics());
    lParams.setMarginStart(mMargin);
    lParams.setMarginEnd(mMargin);
    setLayoutParams(lParams);
    setTextAppearance(context.getResources().getIdentifier(
            "TextAppearance.StatusBar.Clock", "style", PACKAGE_NAME));
    setGravity(Gravity.END | Gravity.CENTER_VERTICAL);

    if (!Utils.isWifiOnly(getContext())) {
        mPhone = (TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
        mPhoneStateListener = new PhoneStateListener() {
            @Override
            public void onDataConnectionStateChanged(int state, int networkType) {
                final boolean connected = state == TelephonyManager.DATA_CONNECTED;
                if (mMobileDataConnected != connected) {
                    mMobileDataConnected = connected;
                    if (DEBUG)
                        log("onDataConnectionStateChanged: mMobileDataConnected=" + mMobileDataConnected);
                    updateState();
                }

            }
        };
    }
}
 
Example 9
Source File: EditPagePort.java    From fingerpoetry-android with Apache License 2.0 5 votes vote down vote up
public void onCreate() {
	super.onCreate();

	int screenHeight = R.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 10
Source File: FriendListPage.java    From POCenter with MIT License 4 votes vote down vote up
private void initTitle(RelativeLayout rlTitle, float ratio) {
	tvCancel = new TextView(activity);
	tvCancel.setTextColor(0xff3b3b3b);
	tvCancel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvCancel.setGravity(Gravity.CENTER);
	int resId = ResHelper.getStringRes(activity, "ssdk_oks_cancel");
	if (resId > 0) {
		tvCancel.setText(resId);
	}
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	tvCancel.setPadding(padding, 0, padding, 0);
	RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	rlTitle.addView(tvCancel, lp);
	tvCancel.setOnClickListener(this);

	TextView tvTitle = new TextView(activity);
	tvTitle.setTextColor(0xff3b3b3b);
	tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
	tvTitle.setGravity(Gravity.CENTER);
	resId = ResHelper.getStringRes(activity, "ssdk_oks_contacts");
	if (resId > 0) {
		tvTitle.setText(resId);
	}
	lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.addRule(RelativeLayout.CENTER_IN_PARENT);
	rlTitle.addView(tvTitle, lp);

	tvConfirm = new TextView(activity);
	tvConfirm.setTextColor(0xffff6d11);
	tvConfirm.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvConfirm.setGravity(Gravity.CENTER);
	resId = ResHelper.getStringRes(activity, "ssdk_oks_confirm");
	if (resId > 0) {
		tvConfirm.setText(resId);
	}
	tvConfirm.setPadding(padding, 0, padding, 0);
	lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	rlTitle.addView(tvConfirm, lp);
	tvConfirm.setOnClickListener(this);
}
 
Example 11
Source File: FriendListPage.java    From YiZhi with Apache License 2.0 4 votes vote down vote up
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);
}
 
Example 12
Source File: EditPageLand.java    From GithubApp with Apache License 2.0 4 votes vote down vote up
private void initTitle(RelativeLayout rlTitle, float ratio) {
	tvCancel = new TextView(activity);
	tvCancel.setTextColor(0xff3b3b3b);
	tvCancel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvCancel.setGravity(Gravity.CENTER);
	int resId = R.getStringRes(activity, "ssdk_oks_cancel");
	if (resId > 0) {
		tvCancel.setText(resId);
	}
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	tvCancel.setPadding(padding, 0, padding, 0);
	RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	rlTitle.addView(tvCancel, lp);
	tvCancel.setOnClickListener(this);

	TextView tvTitle = new TextView(activity);
	tvTitle.setTextColor(0xff3b3b3b);
	tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
	tvTitle.setGravity(Gravity.CENTER);
	resId = R.getStringRes(activity, "ssdk_oks_multi_share");
	if (resId > 0) {
		tvTitle.setText(resId);
	}
	lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.addRule(RelativeLayout.CENTER_IN_PARENT);
	rlTitle.addView(tvTitle, lp);

	tvShare = new TextView(activity);
	tvShare.setTextColor(0xffff6d11);
	tvShare.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvShare.setGravity(Gravity.CENTER);
	resId = R.getStringRes(activity, "ssdk_oks_share");
	if (resId > 0) {
		tvShare.setText(resId);
	}
	tvShare.setPadding(padding, 0, padding, 0);
	lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	rlTitle.addView(tvShare, lp);
	tvShare.setOnClickListener(this);
}
 
Example 13
Source File: AbstractFullFillLayoutHelper.java    From vlayout with MIT License 4 votes vote down vote up
protected LayoutParams generateDefaultLayoutParams() {
    return new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
}
 
Example 14
Source File: EditPagePort.java    From LiuAGeAndroid with MIT License 4 votes vote down vote up
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 15
Source File: PlatformPage.java    From YiZhi with Apache License 2.0 4 votes vote down vote up
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 16
Source File: FriendListPage.java    From GithubApp with Apache License 2.0 4 votes vote down vote up
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);
}
 
Example 17
Source File: GEditTextView.java    From geopaparazzi with GNU General Public License v3.0 4 votes vote down vote up
/**
     * @param context               the context to use.
     * @param attrs                 attributes.
     * @param parentView            parent
     * @param label                 label
     * @param value                 value
     * @param type                  the text type.
     * @param lines                 the lines num.
     * @param constraintDescription constraints
     * @param readonly              if <code>false</code>, the item is disabled for editing.
     */
    public GEditTextView(Context context, AttributeSet attrs, LinearLayout parentView, String label, String value, int type,
                         int lines, String constraintDescription, boolean readonly) {
        super(context, attrs);

        LinearLayout textLayout = new LinearLayout(context);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.WRAP_CONTENT);
        layoutParams.setMargins(10, 10, 10, 10);
        textLayout.setLayoutParams(layoutParams);
        textLayout.setOrientation(LinearLayout.VERTICAL);
        parentView.addView(textLayout);

        TextView textView = new TextView(context);
        textView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        textView.setPadding(2, 2, 2, 2);
        textView.setText(label.replace(UNDERSCORE, " ").replace(COLON, " ") + " " + constraintDescription);
        textView.setTextColor(Compat.getColor(context, R.color.formcolor));

        textLayout.addView(textView);

        editView = new EditText(context);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        params.setMargins(15, 25, 15, 15);
        editView.setLayoutParams(params);
//        editView.setPadding(15, 5, 15, 5);
        editView.setText(value);
        editView.setEnabled(!readonly);

        switch (type) {
            case 1:
                editView.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
                break;
            case 2:
                editView.setInputType(InputType.TYPE_CLASS_PHONE);
                break;
            case 3:
                editView.setInputType(InputType.TYPE_CLASS_DATETIME);
                break;
            case 4:
                editView.setInputType(InputType.TYPE_CLASS_NUMBER);
                break;
            default:
                break;
        }

        if (lines > 0) {
            editView.setLines(lines);
            editView.setGravity(Gravity.TOP);
        }

        textLayout.addView(editView);
    }
 
Example 18
Source File: FriendListPage.java    From fingerpoetry-android with Apache License 2.0 4 votes vote down vote up
private void initTitle(RelativeLayout rlTitle, float ratio) {
	tvCancel = new TextView(activity);
	tvCancel.setTextColor(0xff3b3b3b);
	tvCancel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvCancel.setGravity(Gravity.CENTER);
	int resId = R.getStringRes(activity, "ssdk_oks_cancel");
	if (resId > 0) {
		tvCancel.setText(resId);
	}
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	tvCancel.setPadding(padding, 0, padding, 0);
	RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	rlTitle.addView(tvCancel, lp);
	tvCancel.setOnClickListener(this);

	TextView tvTitle = new TextView(activity);
	tvTitle.setTextColor(0xff3b3b3b);
	tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
	tvTitle.setGravity(Gravity.CENTER);
	resId = R.getStringRes(activity, "ssdk_oks_contacts");
	if (resId > 0) {
		tvTitle.setText(resId);
	}
	lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.addRule(RelativeLayout.CENTER_IN_PARENT);
	rlTitle.addView(tvTitle, lp);

	tvConfirm = new TextView(activity);
	tvConfirm.setTextColor(0xffff6d11);
	tvConfirm.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvConfirm.setGravity(Gravity.CENTER);
	resId = R.getStringRes(activity, "ssdk_oks_confirm");
	if (resId > 0) {
		tvConfirm.setText(resId);
	}
	tvConfirm.setPadding(padding, 0, padding, 0);
	lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	rlTitle.addView(tvConfirm, lp);
	tvConfirm.setOnClickListener(this);
}
 
Example 19
Source File: PlatformPage.java    From Mobike with Apache License 2.0 4 votes vote down vote up
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);

	com.sharesdk.onekeyshare.themes.classic.IndicatorView vInd = new com.sharesdk.onekeyshare.themes.classic.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 20
Source File: DialogGPS.java    From cordova-dialog-gps with MIT License 4 votes vote down vote up
/**
 *  Method that create a new Dialog.   
 *
 *   @param cordova     CordovaInterface to append the dialog created. 
 *                      the dialog is forced to display with the theme light default
 **/
@SuppressLint( "NewApi" )
private AlertDialog.Builder newDialog(CordovaInterface cordova,final String title,final String message, final String description) {
    final Context context = cordova.getActivity().getApplicationContext();
    final String packageName = context.getPackageName();
    AlertDialog.Builder builder;
    int dpi = context.getResources().getDisplayMetrics().densityDpi;
    int currentapiVersion = android.os.Build.VERSION.SDK_INT;
    
    
    if (currentapiVersion >= android.os.Build.VERSION_CODES.HONEYCOMB) {
       builder = new AlertDialog.Builder(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
    } else {
       builder = new AlertDialog.Builder(cordova.getActivity());
    }
    
    builder.setMessage(message);
    builder.setTitle(title);
    
    LinearLayout _layout = new LinearLayout(context);
    LinearLayout.LayoutParams _layout_params  = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
    _layout.setLayoutParams(_layout_params);
    _layout.setPadding(0, dpToPixels(20,dpi),dpToPixels(24,dpi),0);
    _layout.setOrientation(LinearLayout.HORIZONTAL);

    ImageView  _icon = new ImageView(context);
    _icon.setImageResource(cordova.getActivity().getResources().getIdentifier("ic_location","drawable",packageName));
    TextView _description = new TextView(context);
    
    _icon.setLayoutParams(new LinearLayout.LayoutParams(dpToPixels(72,dpi),dpToPixels(72,dpi)));
    _description.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,dpToPixels(72,dpi)));

    _icon.setContentDescription("Location Icon");
    _icon.setPadding(dpToPixels(24,dpi),0,dpToPixels(24,dpi),dpToPixels(24,dpi));
    _icon.setColorFilter(Color.argb(139,0,0,0));
    
    _description.setTextSize(16);
    _description.setText(description);
    _description.setTextColor(Color.argb(139,0,0,0));
    
    _layout.addView(_icon);
    _layout.addView(_description);
    builder.setView(_layout);
    
    return builder;
}