android.widget.LinearLayout.LayoutParams Java Examples

The following examples show how to use android.widget.LinearLayout.LayoutParams. 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: X8TabHost.java    From FimiX8-RE with MIT License 7 votes vote down vote up
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int i;
    int modeWidth = MeasureSpec.getMode(widthMeasureSpec);
    int modeHeight = MeasureSpec.getMode(heightMeasureSpec);
    int sizeWidth = MeasureSpec.getSize(widthMeasureSpec);
    int sizeHeight = MeasureSpec.getSize(heightMeasureSpec);
    if (modeWidth != NTLMConstants.FLAG_NEGOTIATE_KEY_EXCHANGE && this.tabWidth > -1) {
        for (i = 0; i < getChildCount(); i++) {
            ((LayoutParams) ((TextView) getChildAt(i)).getLayoutParams()).width = this.tabWidth;
        }
    }
    if (modeHeight != NTLMConstants.FLAG_NEGOTIATE_KEY_EXCHANGE && this.tabHeight > -1) {
        for (i = 0; i < getChildCount(); i++) {
            ((LayoutParams) ((TextView) getChildAt(i)).getLayoutParams()).height = this.tabHeight;
        }
    }
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
 
Example #2
Source File: EditPage.java    From Huochexing12306 with Apache License 2.0 6 votes vote down vote up
private LinearLayout getBodyBottom() {
	LinearLayout llBottom = new LinearLayout(getContext());
	llBottom.setLayoutParams(new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	String platform = String.valueOf(reqData.get("platform"));
	LinearLayout line = getAtLine(platform);
	if (line != null) {
		llBottom.addView(line);
	}

	// 字数统计
	tvCounter = new TextView(getContext());
	tvCounter.setText(String.valueOf(MAX_TEXT_COUNT));
	tvCounter.setTextColor(0xffcfcfcf);
	tvCounter.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
	tvCounter.setTypeface(Typeface.DEFAULT_BOLD);
	LinearLayout.LayoutParams lpCounter = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpCounter.gravity = Gravity.CENTER_VERTICAL;
	tvCounter.setLayoutParams(lpCounter);
	llBottom.addView(tvCounter);

	return llBottom;
}
 
Example #3
Source File: ExpandAnimation.java    From MVPAndroidBootstrap with Apache License 2.0 6 votes vote down vote up
public static void expand(final View v) {
    v.measure(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    final int targtetHeight = v.getMeasuredHeight();

    v.getLayoutParams().height = 0;
    v.setVisibility(View.VISIBLE);
    Animation a = new Animation()
    {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = interpolatedTime == 1
                    ? LayoutParams.WRAP_CONTENT
                    : (int)(targtetHeight * interpolatedTime);
            v.requestLayout();
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration(500);
    v.startAnimation(a);
}
 
Example #4
Source File: DownExpandAnimation.java    From MVPAndroidBootstrap with Apache License 2.0 6 votes vote down vote up
public static void expand(final View v) {
    v.measure(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    final int targtetHeight = v.getMeasuredHeight();

    v.getLayoutParams().height = 0;
    v.setVisibility(View.VISIBLE);
    Animation a = new Animation()
    {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = interpolatedTime == 1
                    ? LayoutParams.WRAP_CONTENT
                    : (int)(targtetHeight * interpolatedTime);
            v.requestLayout();
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration(500);
    v.startAnimation(a);
}
 
Example #5
Source File: BootstrapDropDown.java    From Android-Bootstrap with MIT License 6 votes vote down vote up
private void createDropDown() {
    ScrollView dropdownView = createDropDownView();
    dropdownWindow = new PopupWindow();
    dropdownWindow.setFocusable(true);
    dropdownWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);

    if (!isInEditMode()) {
        dropdownWindow.setBackgroundDrawable(DrawableUtils.resolveDrawable(android.R.drawable
                                                                                   .dialog_holo_light_frame, getContext()));
    }

    dropdownWindow.setContentView(dropdownView);
    dropdownWindow.setOnDismissListener(this);
    dropdownWindow.setAnimationStyle(android.R.style.Animation_Activity);
    float longestStringWidth = measureStringWidth(getLongestString(dropdownData))
            + DimenUtils.dpToPixels((baselineItemRightPadding + baselineItemLeftPadding) * bootstrapSize);

    if (longestStringWidth < getMeasuredWidth()) {
        dropdownWindow.setWidth(DimenUtils.dpToPixels(getMeasuredWidth()));
    }
    else {
        dropdownWindow.setWidth((int) longestStringWidth + DimenUtils.dpToPixels(8));
    }
}
 
Example #6
Source File: EditPage.java    From BigApp_WordPress_Android with Apache License 2.0 6 votes vote down vote up
private ImageView getImagePin() {
	ivPin = new ImageView(getContext());
	int resId = getBitmapRes(activity, "pin");
	if (resId > 0) {
		ivPin.setImageResource(resId);
	}
	int dp_80 = dipToPx(getContext(), 80);
	int dp_36 = dipToPx(getContext(), 36);
	RelativeLayout.LayoutParams lp
			= new RelativeLayout.LayoutParams(dp_80, dp_36);
	lp.topMargin = dipToPx(getContext(), 6);
	lp.addRule(RelativeLayout.ALIGN_TOP, llBody.getId());
	lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	ivPin.setLayoutParams(lp);
	ivPin.setVisibility(View.GONE);

	return ivPin;
}
 
Example #7
Source File: EditPage.java    From WeCenterMobile-Android with GNU General Public License v2.0 6 votes vote down vote up
private LinearLayout getBodyBottom() {
	LinearLayout llBottom = new LinearLayout(getContext());
	llBottom.setLayoutParams(new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	String platform = String.valueOf(reqData.get("platform"));
	LinearLayout line = getAtLine(platform);
	if (line != null) {
		llBottom.addView(line);
	}

	// 字数统计
	tvCounter = new TextView(getContext());
	tvCounter.setText(String.valueOf(MAX_TEXT_COUNT));
	tvCounter.setTextColor(0xffcfcfcf);
	tvCounter.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
	tvCounter.setTypeface(Typeface.DEFAULT_BOLD);
	LinearLayout.LayoutParams lpCounter = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpCounter.gravity = Gravity.CENTER_VERTICAL;
	tvCounter.setLayoutParams(lpCounter);
	llBottom.addView(tvCounter);

	return llBottom;
}
 
Example #8
Source File: DownExpandAnimation.java    From RxAndroidBootstrap with Apache License 2.0 6 votes vote down vote up
public static void expand(final View v) {
    v.measure(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    final int targtetHeight = v.getMeasuredHeight();

    v.getLayoutParams().height = 0;
    v.setVisibility(View.VISIBLE);
    Animation a = new Animation()
    {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = interpolatedTime == 1
                    ? LayoutParams.WRAP_CONTENT
                    : (int)(targtetHeight * interpolatedTime);
            v.requestLayout();
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration(500);
    v.startAnimation(a);
}
 
Example #9
Source File: EditPage.java    From WeCenterMobile-Android with GNU General Public License v2.0 6 votes vote down vote up
private ImageView getImagePin() {
	ivPin = new ImageView(getContext());
	int resId = getBitmapRes(activity, "pin");
	if (resId > 0) {
		ivPin.setImageResource(resId);
	}
	int dp_80 = dipToPx(getContext(), 80);
	int dp_36 = dipToPx(getContext(), 36);
	RelativeLayout.LayoutParams lp
			= new RelativeLayout.LayoutParams(dp_80, dp_36);
	lp.topMargin = dipToPx(getContext(), 6);
	lp.addRule(RelativeLayout.ALIGN_TOP, llBody.getId());
	lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	ivPin.setLayoutParams(lp);
	ivPin.setVisibility(View.GONE);

	return ivPin;
}
 
Example #10
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 #11
Source File: EditPage.java    From ShareSDKShareDifMsgDemo-Android with MIT License 6 votes vote down vote up
private LinearLayout getBodyBottom() {
	LinearLayout llBottom = new LinearLayout(getContext());
	llBottom.setLayoutParams(new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	String platform = String.valueOf(reqData.get("platform"));
	LinearLayout line = getAtLine(platform);
	if (line != null) {
		llBottom.addView(line);
	}

	// 字数统计
	tvCounter = new TextView(getContext());
	tvCounter.setText(String.valueOf(MAX_TEXT_COUNT));
	tvCounter.setTextColor(0xffcfcfcf);
	tvCounter.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
	tvCounter.setTypeface(Typeface.DEFAULT_BOLD);
	LinearLayout.LayoutParams lpCounter = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpCounter.gravity = Gravity.CENTER_VERTICAL;
	tvCounter.setLayoutParams(lpCounter);
	llBottom.addView(tvCounter);

	return llBottom;
}
 
Example #12
Source File: VideoShotEditActivity.java    From letv with Apache License 2.0 6 votes vote down vote up
public Object instantiateItem(ViewGroup container, int position) {
    RoundedImageView imageView;
    if (VideoShotEditActivity.this.photoFileName.getPhoto().size() > 1 && position == 0) {
        imageView = VideoShotEditActivity.this.createImageViewFromFile(position, ((PhotoInfoBean) VideoShotEditActivity.this.photoFileName.getPhoto().get(VideoShotEditActivity.this.photoFileName.getPhoto().size() - 1)).photoPath);
    } else if (VideoShotEditActivity.this.photoFileName.getPhoto().size() > 1 && position == VideoShotEditActivity.this.photoFileName.getPhoto().size() + 1) {
        imageView = VideoShotEditActivity.this.createImageViewFromFile(position, ((PhotoInfoBean) VideoShotEditActivity.this.photoFileName.getPhoto().get(0)).photoPath);
    } else if (VideoShotEditActivity.this.photoFileName.getPhoto().size() > 1) {
        imageView = VideoShotEditActivity.this.createImageViewFromFile(position, ((PhotoInfoBean) VideoShotEditActivity.this.photoFileName.getPhoto().get(position - 1)).photoPath);
    } else {
        imageView = VideoShotEditActivity.this.createImageViewFromFile(position, ((PhotoInfoBean) VideoShotEditActivity.this.photoFileName.getPhoto().get(position)).photoPath);
    }
    LogInfo.log("fornia", "setupJazziness instantiateItem position:" + position + "|jazzy.getChildCount():" + VideoShotEditActivity.this.jazzy.getChildCount());
    if (imageView != null) {
        imageView.setTag(Integer.valueOf(position));
        imageView.setScaleType(ScaleType.FIT_XY);
        LayoutParams params_imageview = new LayoutParams(-1, -1);
        params_imageview.gravity = 17;
        imageView.setLayoutParams(params_imageview);
        container.addView(imageView, -1, -1);
        VideoShotEditActivity.this.jazzy.setObjectForPosition(imageView, position);
    }
    return imageView;
}
 
Example #13
Source File: EditPage.java    From BigApp_Discuz_Android with Apache License 2.0 6 votes vote down vote up
private ImageView getImagePin() {
	ivPin = new ImageView(getContext());
	int resId = getBitmapRes(activity, "pin");
	if (resId > 0) {
		ivPin.setImageResource(resId);
	}
	int dp_80 = dipToPx(getContext(), 80);
	int dp_36 = dipToPx(getContext(), 36);
	RelativeLayout.LayoutParams lp
			= new RelativeLayout.LayoutParams(dp_80, dp_36);
	lp.topMargin = dipToPx(getContext(), 6);
	lp.addRule(RelativeLayout.ALIGN_TOP, llBody.getId());
	lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	ivPin.setLayoutParams(lp);
	ivPin.setVisibility(View.GONE);

	return ivPin;
}
 
Example #14
Source File: DebugModule.java    From debugdrawer with Apache License 2.0 6 votes vote down vote up
private ViewGroup addChildren(DebugView parent) {
    LayoutInflater inflater = LayoutInflater.from(parent.getContext());
    LinearLayout ll = new LinearLayout(parent.getContext());
    ll.setOrientation(LinearLayout.VERTICAL);
    ll.setLayoutParams(new LayoutParams(MATCH_PARENT,WRAP_CONTENT));

    DisplayMetrics metrics = parent.getContext().getResources().getDisplayMetrics();
    int dp02 = (int) TypedValue.applyDimension(COMPLEX_UNIT_DIP, 2, metrics);
    int dp05 = (int) TypedValue.applyDimension(COMPLEX_UNIT_DIP, 5, metrics);
    ll.setPadding(dp05,dp02,0,0);

    // Attach this module elements and subModule elements
    attachElements(inflater,parent,ll,elements);
    for(DebugModule subModule : subModules) {
        attachElements(inflater,parent,ll,subModule.getElements());
    }

    return ll;
}
 
Example #15
Source File: MainActivity.java    From spidey with GNU General Public License v3.0 6 votes vote down vote up
public void addView(View view, int margin) {
	/**
	 * <Button android:text="Scan Result 1" android:textSize="24sp"
	 * android:textColor="#000000"
	 * 
	 * android:background="#cc999999"
	 * android:layout_height="wrap_content"
	 * android:layout_width="match_parent" android:gravity="center"
	 * android:layout_margin="6dp"
	 */
	
	LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT,
			LayoutParams.WRAP_CONTENT);
	lp.setMargins(margin,margin,margin,margin);
	mViewResults.addView(view, lp);
	
	
}
 
Example #16
Source File: WaitPDPActivity.java    From DroidForce with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Setup the layout for the activity
 */
private void setLayout() {		
	Log.i("DroidForce", "Setting up layout...");
	LinearLayout llayout = new LinearLayout(this);

	LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams( 
			LinearLayout.LayoutParams.FILL_PARENT,
			LinearLayout.LayoutParams.FILL_PARENT);

	llayout.setBackgroundDrawable(loadBackground());
	llayout.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
	
       TextView tv = new TextView(this);
       LayoutParams lpView = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
       tv.setText("Powered by DroidForce.");
       tv.setLayoutParams(lpView);  
       
       llayout.addView(tv);
	
	setContentView(llayout);
	

}
 
Example #17
Source File: EditPage.java    From BigApp_WordPress_Android with Apache License 2.0 6 votes vote down vote up
private LinearLayout getBodyBottom() {
	LinearLayout llBottom = new LinearLayout(getContext());
	llBottom.setLayoutParams(new LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	LinearLayout line = getAtLine(platforms.get(0).getName());
	if (line != null) {
		llBottom.addView(line);
	}

	// Words counter
	tvCounter = new TextView(getContext());
	tvCounter.setText(String.valueOf(MAX_TEXT_COUNT));
	tvCounter.setTextColor(0xffcfcfcf);
	tvCounter.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
	tvCounter.setTypeface(Typeface.DEFAULT_BOLD);
	LayoutParams lpCounter = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpCounter.gravity = Gravity.CENTER_VERTICAL;
	tvCounter.setLayoutParams(lpCounter);
	llBottom.addView(tvCounter);

	return llBottom;
}
 
Example #18
Source File: MaterialDatePicker.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onStart() {
  super.onStart();
  Window window = requireDialog().getWindow();
  // Dialogs use a background with an InsetDrawable by default, so we have to replace it.
  if (fullscreen) {
    window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    window.setBackgroundDrawable(background);
  } else {
    window.setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    int inset =
        getResources().getDimensionPixelOffset(R.dimen.mtrl_calendar_dialog_background_inset);
    Rect insets = new Rect(inset, inset, inset, inset);
    window.setBackgroundDrawable(new InsetDrawable(background, inset, inset, inset, inset));
    window
        .getDecorView()
        .setOnTouchListener(new InsetDialogOnTouchListener(requireDialog(), insets));
  }
  startPickerFragment();
}
 
Example #19
Source File: MainBottomNavigationView.java    From letv with Apache License 2.0 6 votes vote down vote up
public void setNavigations() {
    removeAllViews();
    int height = UIsUtils.dipToPx(49.0f);
    NavigationType[] types = NavigationType.values();
    int len = types.length;
    for (int i = 0; i < len; i++) {
        LayoutParams params = new LayoutParams(height, height);
        if (i == 0) {
            params.leftMargin = UIsUtils.dipToPx(14.0f);
        } else {
            params.leftMargin = ((UIsUtils.getScreenWidth() - (UIsUtils.dipToPx(14.0f) * 2)) - (len * height)) / (len - 1);
        }
        BottomNavigationItemView itemView = new BottomNavigationItemView(this, this.mContext);
        itemView.setData(types[i]);
        addView(itemView, params);
    }
    setSelectedType(NavigationType.HOME);
}
 
Example #20
Source File: LoginActivity.java    From CC with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    callId = CCUtil.getNavigateCallId(this);
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setPadding(20, 20, 20, 20);
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    editText = new EditText(this);
    editText.setHint(R.string.demo_b_username_hint);
    editText.setText("billy");
    layout.addView(editText, params);
    Button button = new Button(this);
    button.setText(R.string.demo_b_click_login);
    button.setOnClickListener(this);
    layout.addView(button, params);
    setContentView(layout);
}
 
Example #21
Source File: EditPage.java    From AndroidLinkup 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 #22
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 #23
Source File: EditPage.java    From -Android_ShareSDK_Example_Wechat with MIT License 5 votes vote down vote up
public void setActivity(Activity activity) {
	super.setActivity(activity);
	if (dialogMode) {
		activity.setTheme(android.R.style.Theme_Dialog);
		activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
	}
	activity.getWindow().setSoftInputMode(
		       WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
 
Example #24
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 #25
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 #26
Source File: AlbumHalfFragment.java    From letv with Apache License 2.0 5 votes vote down vote up
private void updateExpandLayoutParams() {
    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(-1, -1);
    if (UIsUtils.isLandscape(this.mActivity)) {
        lp.width = AlbumPlayActivity.LANDSCAPE_EXPAND_WIDTH;
        lp.addRule(11);
    } else {
        lp.topMargin = this.mActivity.getHalfVideoHeight();
        lp.addRule(10);
    }
    this.mFragmentContain.setLayoutParams(lp);
}
 
Example #27
Source File: IMPopupDialog.java    From opensudoku with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates view with two tabs, first for number in cell selection, second for
 * note editing.
 *
 * @return
 */
private TabHost createTabView() {
    TabHost tabHost = new TabHost(mContext, null);
    tabHost.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    //tabHost.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    LinearLayout linearLayout = new LinearLayout(mContext);
    linearLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    //linearLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    linearLayout.setOrientation(LinearLayout.VERTICAL);

    TabWidget tabWidget = new TabWidget(mContext);
    tabWidget.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    tabWidget.setId(android.R.id.tabs);

    FrameLayout frameLayout = new FrameLayout(mContext);
    frameLayout.setId(android.R.id.tabcontent);

    linearLayout.addView(tabWidget);
    linearLayout.addView(frameLayout);
    tabHost.addView(linearLayout);

    tabHost.setup();

    final View editNumberView = createEditNumberView();
    final View editNoteView = createEditNoteView();

    tabHost.addTab(tabHost.newTabSpec("number")
            .setIndicator(mContext.getString(R.string.select_number))
            .setContent(tag -> editNumberView));
    tabHost.addTab(tabHost.newTabSpec("note")
            .setIndicator(mContext.getString(R.string.edit_note))
            .setContent(tag -> editNoteView));

    return tabHost;
}
 
Example #28
Source File: TopRecommendFragment.java    From letv with Apache License 2.0 5 votes vote down vote up
private void makeGallerySwitchBackGround(LinearLayout gallerySwtichLayout, int count) {
    int childCount = gallerySwtichLayout.getChildCount();
    if (count > childCount) {
        count -= childCount;
        for (int i = 0; i < count; i++) {
            ImageView itemImageView = new ImageView(getActivity());
            itemImageView.setLayoutParams(new LayoutParams(-2, -2));
            itemImageView.setImageResource(2130838158);
            itemImageView.setPadding(5, 0, 5, 0);
            gallerySwtichLayout.addView(itemImageView, childCount + i);
        }
    }
}
 
Example #29
Source File: PopuWindowView.java    From KUtils with Apache License 2.0 5 votes vote down vote up
public PopuWindowView(Context mContext, int widthGravity) {
    this.mContext = mContext;
    LayoutInflater inflater = LayoutInflater.from(mContext);
    viewItem = inflater.inflate(R.layout.dialogui_popu_options, null);
    pupoListView = (ListView) viewItem.findViewById(R.id.customui_list);
    mPopuWindowAdapter = new PopuWindowAdapter(mContext, popuLists);
    pupoListView.setAdapter(mPopuWindowAdapter);
    pullDownView = new PopupWindow(viewItem, widthGravity,
            LayoutParams.WRAP_CONTENT, true);
    pullDownView.setOutsideTouchable(true);
    pullDownView.setBackgroundDrawable(new BitmapDrawable());
    pupoListView.setOnItemClickListener(this);
}
 
Example #30
Source File: UIActionSheetDialog.java    From Auie with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 构建视图
 * @return
 */
@SuppressWarnings("deprecation")
private UIActionSheetDialog builder() {
	setBackgroundDrawable(new BitmapDrawable());
	if (type == 0) {
		setContentView(createContentViewForIOS());
	}else {
		setContentView(createContentViewForANDROID());
	}
	setWidth(WIDTH);
	setHeight(android.view.ViewGroup.LayoutParams.MATCH_PARENT);
	setFocusable(true);
	return this;
}