Java Code Examples for android.widget.LinearLayout.LayoutParams#WRAP_CONTENT

The following examples show how to use android.widget.LinearLayout.LayoutParams#WRAP_CONTENT . 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: EditPage.java    From BigApp_WordPress_Android with Apache License 2.0 6 votes vote down vote up
private RelativeLayout getPageView() {
	rlPage = new RelativeLayout(getContext());
	rlPage.setBackgroundDrawable(background);
	if (dialogMode) {
		RelativeLayout rlDialog = new RelativeLayout(getContext());
		rlDialog.setBackgroundColor(0xc0323232);
		int dp_8 = dipToPx(getContext(), 8);
		int width = getScreenWidth(getContext()) - dp_8 * 2;
		RelativeLayout.LayoutParams lpDialog = new RelativeLayout.LayoutParams(
				width, LayoutParams.WRAP_CONTENT);
		lpDialog.topMargin = dp_8;
		lpDialog.bottomMargin = dp_8;
		lpDialog.addRule(RelativeLayout.CENTER_IN_PARENT);
		rlDialog.setLayoutParams(lpDialog);
		rlPage.addView(rlDialog);

		rlDialog.addView(getPageTitle());
		rlDialog.addView(getPageBody());
		rlDialog.addView(getImagePin());
	} else {
		rlPage.addView(getPageTitle());
		rlPage.addView(getPageBody());
		rlPage.addView(getImagePin());
	}
	return rlPage;
}
 
Example 2
Source File: EditPage.java    From WeCenterMobile-Android with GNU General Public License v2.0 6 votes vote down vote up
private RelativeLayout getPageView() {
	rlPage = new RelativeLayout(getContext());
	rlPage.setBackgroundDrawable(background);
	if (dialogMode) {
		RelativeLayout rlDialog = new RelativeLayout(getContext());
		rlDialog.setBackgroundColor(0xc0323232);
		int dp_8 = dipToPx(getContext(), 8);
		int width = getScreenWidth(getContext()) - dp_8 * 2;
		RelativeLayout.LayoutParams lpDialog = new RelativeLayout.LayoutParams(
				width, LayoutParams.WRAP_CONTENT);
		lpDialog.topMargin = dp_8;
		lpDialog.bottomMargin = dp_8;
		lpDialog.addRule(RelativeLayout.CENTER_IN_PARENT);
		rlDialog.setLayoutParams(lpDialog);
		rlPage.addView(rlDialog);

		rlDialog.addView(getPageTitle());
		rlDialog.addView(getPageBody());
		rlDialog.addView(getImagePin());
	} else {
		rlPage.addView(getPageTitle());
		rlPage.addView(getPageBody());
		rlPage.addView(getImagePin());
	}
	return rlPage;
}
 
Example 3
Source File: EditPage.java    From ShareSDKShareDifMsgDemo-Android with MIT License 6 votes vote down vote up
private RelativeLayout getPageView() {
	rlPage = new RelativeLayout(getContext());
	rlPage.setBackgroundDrawable(background);
	if (dialogMode) {
		RelativeLayout rlDialog = new RelativeLayout(getContext());
		rlDialog.setBackgroundColor(0xc0323232);
		int dp_8 = dipToPx(getContext(), 8);
		int width = getScreenWidth(getContext()) - dp_8 * 2;
		RelativeLayout.LayoutParams lpDialog = new RelativeLayout.LayoutParams(
				width, LayoutParams.WRAP_CONTENT);
		lpDialog.topMargin = dp_8;
		lpDialog.bottomMargin = dp_8;
		lpDialog.addRule(RelativeLayout.CENTER_IN_PARENT);
		rlDialog.setLayoutParams(lpDialog);
		rlPage.addView(rlDialog);

		rlDialog.addView(getPageTitle());
		rlDialog.addView(getPageBody());
		rlDialog.addView(getImagePin());
	} else {
		rlPage.addView(getPageTitle());
		rlPage.addView(getPageBody());
		rlPage.addView(getImagePin());
	}
	return rlPage;
}
 
Example 4
Source File: EmptyFragment.java    From secureit with MIT License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {    	
	
    if ((savedInstanceState != null) && savedInstanceState.containsKey(CONTENT)) {
        mContent = savedInstanceState.getString(CONTENT);
    }
	
    TextView text = new TextView(getActivity());
    text.setGravity(Gravity.CENTER);
    text.setText(mContent);
    text.setTextSize(20 * getResources().getDisplayMetrics().density);

    RelativeLayout layout = new RelativeLayout(getActivity());
    layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    layout.setGravity(Gravity.CENTER);
    
    RelativeLayout alert = new RelativeLayout(getActivity());
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.leftMargin = 20;
    params.rightMargin = 20;
    params.addRule(RelativeLayout.CENTER_HORIZONTAL);
    params.addRule(RelativeLayout.CENTER_IN_PARENT);
    alert.setLayoutParams(params);
    alert.setBackgroundResource(R.drawable.red_back);
    alert.setPadding(30, 0, 30, 0);
    alert.addView(text);
    layout.addView(alert);
  
    return layout;
}
 
Example 5
Source File: RationaleDialog.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
public static AlertDialog.Builder createFor(@NonNull Context context, @NonNull String message, @DrawableRes int... drawables) {
  View      view   = LayoutInflater.from(context).inflate(R.layout.permissions_rationale_dialog, null);
  ViewGroup header = view.findViewById(R.id.header_container);
  TextView  text   = view.findViewById(R.id.message);

  for (int i=0;i<drawables.length;i++) {
    Drawable drawable = ContextCompat.getDrawable(context, drawables[i]);
    DrawableCompat.setTint(drawable, ContextCompat.getColor(context, R.color.white));
    ImageView imageView = new ImageView(context);
    imageView.setImageDrawable(drawable);
    imageView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    header.addView(imageView);

    if (i != drawables.length - 1) {
      TextView plus = new TextView(context);
      plus.setText("+");
      plus.setTextSize(TypedValue.COMPLEX_UNIT_SP, 40);
      plus.setTextColor(Color.WHITE);

      LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      layoutParams.setMargins(ViewUtil.dpToPx(context, 20), 0, ViewUtil.dpToPx(context, 20), 0);

      plus.setLayoutParams(layoutParams);
      header.addView(plus);
    }
  }

  text.setText(message);

  return new AlertDialog.Builder(context, ThemeUtil.isDarkTheme(context) ? R.style.Theme_Signal_AlertDialog_Dark_Cornered : R.style.Theme_Signal_AlertDialog_Light_Cornered)
                        .setView(view);
}
 
Example 6
Source File: SimpleDialog.java    From microMathematics with GNU General Public License v3.0 5 votes vote down vote up
public void disableButton(int id)
{
    View button = findViewById(id);
    final View other = findViewById(id == R.id.dialog_button_ok ? R.id.dialog_button_cancel : R.id.dialog_button_ok);
    if (button != null && other != null)
    {
        button.setVisibility(View.GONE);
        LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        lp.setMargins(0, 0, 0, getContext().getResources().getDimensionPixelSize(R.dimen.dialog_buttons_margin));
        other.setLayoutParams(lp);
        findViewById(R.id.dialog_button_devider).setVisibility(View.GONE);
    }
}
 
Example 7
Source File: EditPage.java    From WeCenterMobile-Android with GNU General Public License v2.0 5 votes vote down vote up
private TitleLayout getPageTitle() {
		llTitle = new TitleLayout(getContext());
		llTitle.setId(1);
//		int resId = getBitmapRes(activity, "title_back");
//		if (resId > 0) {
//			llTitle.setBackgroundResource(resId);
//		}
		llTitle.getBtnBack().setOnClickListener(this);
		int resId = getStringRes(activity, "multi_share");
		if (resId > 0) {
			llTitle.getTvTitle().setText(resId);
		}
		llTitle.getBtnRight().setVisibility(View.VISIBLE);
		resId = getStringRes(activity, "share");
		if (resId > 0) {
			llTitle.getBtnRight().setText(resId);
		}
		llTitle.getBtnRight().setOnClickListener(this);
		RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
		lp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
		lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
		llTitle.setLayoutParams(lp);

		return llTitle;
	}
 
Example 8
Source File: FollowList.java    From AndroidLinkup with GNU General Public License v2.0 5 votes vote down vote up
public PRTHeader(Context context) {
	super(context);
	setOrientation(VERTICAL);

	LinearLayout llInner = new LinearLayout(context);
	LinearLayout.LayoutParams lpInner = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpInner.gravity = Gravity.CENTER_HORIZONTAL;
	addView(llInner, lpInner);

	ivArrow = new RotateImageView(context);
	int resId = getBitmapRes(context, "ssdk_oks_ptr_ptr");
	if (resId > 0) {
		ivArrow.setImageResource(resId);
	}
	int dp_32 = dipToPx(context, 32);
	LayoutParams lpIv = new LayoutParams(dp_32, dp_32);
	lpIv.gravity = Gravity.CENTER_VERTICAL;
	llInner.addView(ivArrow, lpIv);

	pbRefreshing = new ProgressBar(context);
	llInner.addView(pbRefreshing, lpIv);
	pbRefreshing.setVisibility(View.GONE);

	tvHeader = new TextView(getContext());
	tvHeader.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
	tvHeader.setGravity(Gravity.CENTER);
	int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 10);
	tvHeader.setPadding(dp_10, dp_10, dp_10, dp_10);
	tvHeader.setTextColor(0xff000000);
	LayoutParams lpTv = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpTv.gravity = Gravity.CENTER_VERTICAL;
	llInner.addView(tvHeader, lpTv);
}
 
Example 9
Source File: FollowListPage.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
public PRTHeader(Context context) {
	super(context);
	setOrientation(VERTICAL);

	LinearLayout llInner = new LinearLayout(context);
	LinearLayout.LayoutParams lpInner = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpInner.gravity = Gravity.CENTER_HORIZONTAL;
	addView(llInner, lpInner);

	ivArrow = new RotateImageView(context);
	int resId = getBitmapRes(context, "ssdk_oks_ptr_ptr");
	if (resId > 0) {
		ivArrow.setImageResource(resId);
	}
	int dp_32 = dipToPx(context, 32);
	LayoutParams lpIv = new LayoutParams(dp_32, dp_32);
	lpIv.gravity = Gravity.CENTER_VERTICAL;
	llInner.addView(ivArrow, lpIv);

	pbRefreshing = new ProgressBar(context);
	llInner.addView(pbRefreshing, lpIv);
	pbRefreshing.setVisibility(View.GONE);

	tvHeader = new TextView(getContext());
	tvHeader.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
	tvHeader.setGravity(Gravity.CENTER);
	int dp_10 = com.mob.tools.utils.R.dipToPx(getContext(), 10);
	tvHeader.setPadding(dp_10, dp_10, dp_10, dp_10);
	tvHeader.setTextColor(0xff000000);
	LayoutParams lpTv = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpTv.gravity = Gravity.CENTER_VERTICAL;
	llInner.addView(tvHeader, lpTv);
}
 
Example 10
Source File: EditPage.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
private TitleLayout getPageTitle() {
		llTitle = new TitleLayout(getContext());
		llTitle.setId(1);
//		int resId = getBitmapRes(activity, "title_back");
//		if (resId > 0) {
//			llTitle.setBackgroundResource(resId);
//		}

		int resIdBackgroundColor = getColorRes(activity, "bg_title");
		if (resIdBackgroundColor > 0) {
			llTitle.setBackgroundColor(activity.getResources().getColor(resIdBackgroundColor));
			Log.d("resIdBackgroundColor","resIdBackgroundColor:"+resIdBackgroundColor);
		}

		llTitle.getBtnBack().setOnClickListener(this);
		int resId = getStringRes(activity, "multi_share");
		if (resId > 0) {
			llTitle.getTvTitle().setText(resId);
		}
		llTitle.getBtnRight().setVisibility(View.VISIBLE);
		resId = getStringRes(activity, "share");
		if (resId > 0) {
			llTitle.getBtnRight().setText(resId);
		}
		llTitle.getBtnRight().setOnClickListener(this);
		RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
		lp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
		lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
		llTitle.setLayoutParams(lp);

		return llTitle;
	}
 
Example 11
Source File: RationaleDialog.java    From Silence with GNU General Public License v3.0 5 votes vote down vote up
public static AlertDialog.Builder createFor(@NonNull Context context, @NonNull String message, @DrawableRes int... drawables) {
  View      view   = LayoutInflater.from(context).inflate(R.layout.permissions_rationale_dialog, null);
  ViewGroup header = view.findViewById(R.id.header_container);
  TextView  text   = view.findViewById(R.id.message);

  for (int i=0;i<drawables.length;i++) {
    ImageView imageView = new ImageView(context);
    imageView.setImageDrawable(context.getResources().getDrawable(drawables[i]));
    imageView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    header.addView(imageView);

    if (i != drawables.length - 1) {
      TextView plus = new TextView(context);
      plus.setText("+");
      plus.setTextSize(TypedValue.COMPLEX_UNIT_SP, 40);
      plus.setTextColor(Color.WHITE);

      LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      layoutParams.setMargins(ViewUtil.dpToPx(context, 20), 0, ViewUtil.dpToPx(context, 20), 0);

      plus.setLayoutParams(layoutParams);
      header.addView(plus);
    }
  }

  text.setText(message);

  return new AlertDialog.Builder(context, R.style.RationaleDialog).setView(view);
}
 
Example 12
Source File: NumberPickerPreference.java    From AndroidMaterialPreferences with Apache License 2.0 5 votes vote down vote up
@CallSuper
@Override
protected void onPrepareDialog(
        @NonNull final AbstractButtonBarDialogBuilder<?, ?> dialogBuilder) {
    View view = View.inflate(dialogBuilder.getContext(), R.layout.number_picker, null);
    view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    LinearLayout container = view.findViewById(R.id.number_picker_container);

    String[] displayedValues = createDisplayedValues();
    numberPicker = new NumberPicker(dialogBuilder.getContext());
    numberPicker.setDisplayedValues(displayedValues);
    numberPicker.setMinValue(0);
    numberPicker.setMaxValue(displayedValues.length - 1);
    numberPicker.setValue(
            Math.round((float) (getCurrentIndex() - getMinNumber()) / (float) getStepSize()));
    numberPicker.setWrapSelectorWheel(isSelectorWheelWrapped());
    numberPicker.setDescendantFocusability(
            isInputMethodUsed() ? NumberPicker.FOCUS_BEFORE_DESCENDANTS :
                    NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    numberPicker.setOnValueChangedListener(createNumberPickerListener());
    LayoutParams layoutParams =
            new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    container.addView(numberPicker, 0, layoutParams);

    TextView unitTextView = container.findViewById(R.id.unit_text_view);
    unitTextView.setText(getUnit());
    unitTextView.setVisibility(TextUtils.isEmpty(getUnit()) ? View.GONE : View.VISIBLE);

    dialogBuilder.setView(view);
}
 
Example 13
Source File: EditPage.java    From ShareSDKShareDifMsgDemo-Android with MIT License 5 votes vote down vote up
private LinearLayout getPlatformList() {
	LinearLayout llToolBar = new LinearLayout(getContext());
	LinearLayout.LayoutParams lpTb = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	llToolBar.setLayoutParams(lpTb);

	TextView tvShareTo = new TextView(getContext());
	int resId = getStringRes(activity, "share_to");
	if (resId > 0) {
		tvShareTo.setText(resId);
	}
	tvShareTo.setTextColor(0xffcfcfcf);
	tvShareTo.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
	int dp_9 = dipToPx(getContext(), 9);
	LinearLayout.LayoutParams lpShareTo = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpShareTo.gravity = Gravity.CENTER_VERTICAL;
	lpShareTo.setMargins(dp_9, 0, 0, 0);
	tvShareTo.setLayoutParams(lpShareTo);
	llToolBar.addView(tvShareTo);

	HorizontalScrollView sv = new HorizontalScrollView(getContext());
	sv.setHorizontalScrollBarEnabled(false);
	sv.setHorizontalFadingEdgeEnabled(false);
	LinearLayout.LayoutParams lpSv = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpSv.setMargins(dp_9, dp_9, dp_9, dp_9);
	sv.setLayoutParams(lpSv);
	llToolBar.addView(sv);

	llPlat = new LinearLayout(getContext());
	llPlat.setLayoutParams(new HorizontalScrollView.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
	sv.addView(llPlat);

	return llToolBar;
}
 
Example 14
Source File: BaseActivity.java    From android-lite-orm with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.act_list_btn);
    TAG = this.getClass().getSimpleName();
    OrmLog.setTag(TAG);

    container = (LinearLayout) findViewById(R.id.container);
    scroll = (ScrollView) container.getParent();
    TextView tv = (TextView) container.findViewById(R.id.title);
    tv.setText(getMainTitle());
    mTvSubTitle = (TextView) container.findViewById(R.id.sub_title);

    String[] bttxt = getButtonTexts();
    if (bttxt != null) {
        for (int i = 0; i < bttxt.length; i++) {
            Button bt = new Button(this);
            LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
            int margin = getResources().getDimensionPixelSize(R.dimen.common_marin);
            lp.setMargins(margin, margin, margin, margin);
            bt.setId(i);
            bt.setText(bttxt[i]);
            bt.setOnClickListener(this);
            bt.setLayoutParams(lp);
            container.addView(bt);
        }
    }
}
 
Example 15
Source File: PullToRefreshListViewHeader.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
/**
 * show footer
 */
public void show() {
	LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mContentView
			.getLayoutParams();
	lp.height = LayoutParams.WRAP_CONTENT;
	mContentView.setLayoutParams(lp);
}
 
Example 16
Source File: EditPage.java    From ShareSDKShareDifMsgDemo-Android with MIT License 5 votes vote down vote up
private TitleLayout getPageTitle() {
		llTitle = new TitleLayout(getContext());
		llTitle.setId(1);
//		int resId = getBitmapRes(activity, "title_back");
//		if (resId > 0) {
//			llTitle.setBackgroundResource(resId);
//		}
		llTitle.getBtnBack().setOnClickListener(this);
		int resId = getStringRes(activity, "multi_share");
		if (resId > 0) {
			llTitle.getTvTitle().setText(resId);
		}
		llTitle.getBtnRight().setVisibility(View.VISIBLE);
		resId = getStringRes(activity, "share");
		if (resId > 0) {
			llTitle.getBtnRight().setText(resId);
		}
		llTitle.getBtnRight().setOnClickListener(this);
		RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
		lp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
		lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
		llTitle.setLayoutParams(lp);

		return llTitle;
	}
 
Example 17
Source File: ChartsActivity.java    From CameraV with GNU General Public License v3.0 4 votes vote down vote up
private LineChart addChart (String label, LineData data)
{
	LineChart chart = new LineChart(this);
       //chart.setOnChartGestureListener(this);
       //chart.setOnChartValueSelectedListener(this);

	chart.getAxisLeft().setStartAtZero(false);
	
       // no description text
       chart.setDescription("");
       chart.setNoDataTextDescription("");

       // enable value highlighting
       chart.setHighlightEnabled(true);

       // enable touch gestures
       chart.setTouchEnabled(true);

       // enable scaling and dragging
       chart.setDragEnabled(true);
       chart.setScaleEnabled(true);
       // chart.setScaleXEnabled(true);
       // chart.setScaleYEnabled(true);

       // if disabled, scaling can be done on x- and y-axis separately
       chart.setPinchZoom(true);

       // set data
       chart.setData(data);        
      
       TextView tv = new TextView (this);
       tv.setText(label);        
       LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
               LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);     
       
       viewChartGroup.addView(tv,params);
       
       int dpHeight = 300;
      
       int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpHeight, getResources().getDisplayMetrics());

       params = new LinearLayout.LayoutParams(
               LayoutParams.MATCH_PARENT, height);     
       
       int dpMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3, getResources().getDisplayMetrics());
       params.setMargins(dpMargin,dpMargin,dpMargin,dpMargin);
       
       chart.setLayoutParams(params);              
       
       viewChartGroup.addView(chart,params);
       
       return chart;
}
 
Example 18
Source File: FollowListPage.java    From BigApp_Discuz_Android with Apache License 2.0 4 votes vote down vote up
public void onCreate() {
	LinearLayout llPage = new LinearLayout(getContext());
	llPage.setBackgroundColor(0xfff5f5f5);
	llPage.setOrientation(LinearLayout.VERTICAL);
	activity.setContentView(llPage);

	// 标题栏
	llTitle = new TitleLayout(getContext());
	int resId = getBitmapRes(getContext(), "title_back");
	if (resId > 0) {
		llTitle.setBackgroundResource(resId);
	}
	llTitle.getBtnBack().setOnClickListener(this);
	resId = getStringRes(getContext(), "multi_share");
	if (resId > 0) {
		llTitle.getTvTitle().setText(resId);
	}
	llTitle.getBtnRight().setVisibility(View.VISIBLE);
	resId = getStringRes(getContext(), "finish");
	if (resId > 0) {
		llTitle.getBtnRight().setText(resId);
	}
	llTitle.getBtnRight().setOnClickListener(this);
	llTitle.setLayoutParams(new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	llPage.addView(llTitle);

	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);

	// 关注(或朋友)列表
	PullToRefreshView followList = new PullToRefreshView(getContext());
	FrameLayout.LayoutParams lpLv = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	followList.setLayoutParams(lpLv);
	flPage.addView(followList);
	adapter = new FollowAdapter(followList);
	adapter.setPlatform(platform);
	followList.setAdapter(adapter);
	adapter.getListView().setOnItemClickListener(this);

	ImageView ivShadow = new ImageView(getContext());
	resId = getBitmapRes(getContext(), "title_shadow");
	if (resId > 0) {
		ivShadow.setBackgroundResource(resId);
	}
	FrameLayout.LayoutParams lpSd = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	ivShadow.setLayoutParams(lpSd);
	flPage.addView(ivShadow);

	// 请求数据
	followList.performPulling(true);
}
 
Example 19
Source File: ActionSheetDialog.java    From FlycoDialog_Master with MIT License 4 votes vote down vote up
@Override
public View onCreateView() {
    LinearLayout ll_container = new LinearLayout(mContext);
    ll_container.setOrientation(LinearLayout.VERTICAL);
    ll_container.setBackgroundColor(Color.TRANSPARENT);

    /** title */
    mTvTitle = new TextView(mContext);
    mTvTitle.setGravity(Gravity.CENTER);
    mTvTitle.setPadding(dp2px(10), dp2px(5), dp2px(10), dp2px(5));

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.topMargin = dp2px(20);

    ll_container.addView(mTvTitle, params);

    /** title underline */
    mVLineTitle = new View(mContext);
    ll_container.addView(mVLineTitle);

    /** listview */
    mLv = new ListView(mContext);
    mLv.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1));
    mLv.setCacheColorHint(Color.TRANSPARENT);
    mLv.setFadingEdgeLength(0);
    mLv.setVerticalScrollBarEnabled(false);
    mLv.setSelector(new ColorDrawable(Color.TRANSPARENT));

    ll_container.addView(mLv);

    /** mCancel btn */
    mTvCancel = new TextView(mContext);
    mTvCancel.setGravity(Gravity.CENTER);
    LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lp.topMargin = dp2px(7);
    lp.bottomMargin = dp2px(7);
    mTvCancel.setLayoutParams(lp);

    ll_container.addView(mTvCancel);

    return ll_container;
}
 
Example 20
Source File: FollowListPage.java    From BigApp_Discuz_Android with Apache License 2.0 4 votes vote down vote up
public void onCreate() {
	LinearLayout llPage = new LinearLayout(getContext());
	llPage.setBackgroundColor(0xfff5f5f5);
	llPage.setOrientation(LinearLayout.VERTICAL);
	activity.setContentView(llPage);

	// 标题栏
	llTitle = new TitleLayout(getContext());
	int resId = getBitmapRes(getContext(), "title_back");
	if (resId > 0) {
		llTitle.setBackgroundResource(resId);
	}
	llTitle.getBtnBack().setOnClickListener(this);
	resId = getStringRes(getContext(), "multi_share");
	if (resId > 0) {
		llTitle.getTvTitle().setText(resId);
	}
	llTitle.getBtnRight().setVisibility(View.VISIBLE);
	resId = getStringRes(getContext(), "finish");
	if (resId > 0) {
		llTitle.getBtnRight().setText(resId);
	}
	llTitle.getBtnRight().setOnClickListener(this);
	llTitle.setLayoutParams(new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	llPage.addView(llTitle);

	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);

	// 关注(或朋友)列表
	PullToRefreshView followList = new PullToRefreshView(getContext());
	FrameLayout.LayoutParams lpLv = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	followList.setLayoutParams(lpLv);
	flPage.addView(followList);
	adapter = new FollowAdapter(followList);
	adapter.setPlatform(platform);
	followList.setAdapter(adapter);
	adapter.getListView().setOnItemClickListener(this);

	ImageView ivShadow = new ImageView(getContext());
	resId = getBitmapRes(getContext(), "title_shadow");
	if (resId > 0) {
		ivShadow.setBackgroundResource(resId);
	}
	FrameLayout.LayoutParams lpSd = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	ivShadow.setLayoutParams(lpSd);
	flPage.addView(ivShadow);

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