com.google.android.material.textfield.TextInputLayout.getLayoutParams()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中com.google.android.material.textfield.TextInputLayout.getLayoutParams()方法的一些代码示例,展示了TextInputLayout.getLayoutParams()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextInputLayout.getLayoutParams()方法的具体详情如下:
包路径:com.google.android.material.textfield.TextInputLayout
类名称:TextInputLayout
方法名:getLayoutParams

TextInputLayout.getLayoutParams介绍

暂无

代码示例

代码示例来源:origin: stripe/stripe-android

void adjustViewForPostalCodeAttribute() {
  // Set the label/hint to the shorter value if we have three things in a row.
  @StringRes final int expiryLabel = mShouldShowPostalCode
      ? R.string.expiry_label_short
      : R.string.acc_label_expiry_date;
  mExpiryTextInputLayout.setHint(getResources().getString(expiryLabel));
  @IdRes final int focusForward = mShouldShowPostalCode
      ? R.id.et_add_source_postal_ml
      : NO_ID;
  mCvcEditText.setNextFocusForwardId(focusForward);
  mCvcEditText.setNextFocusDownId(focusForward);
  final int postalCodeVisibility = mShouldShowPostalCode ? View.VISIBLE : View.GONE;
  mPostalInputLayout.setVisibility(postalCodeVisibility);
  // If the postal code field is not shown, the CVC field is the last one in the form and the
  // action on the keyboard when the CVC field is focused should be "Done". Otherwise, show
  // the "Next" action.
  mCvcEditText.setImeOptions(postalCodeVisibility == View.GONE ?
      EditorInfo.IME_ACTION_DONE : EditorInfo.IME_ACTION_NEXT);
  final int marginPixels = mShouldShowPostalCode
      ? getResources().getDimensionPixelSize(R.dimen.add_card_expiry_middle_margin)
      : 0;
  final LinearLayout.LayoutParams linearParams =
      (LinearLayout.LayoutParams) mCvcTextInputLayout.getLayoutParams();
  linearParams.setMargins(0, 0, marginPixels, 0);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
    linearParams.setMarginEnd(marginPixels);
  }
  mCvcTextInputLayout.setLayoutParams(linearParams);
}

代码示例来源:origin: stripe/stripe-android

@Test
public void initView_whenZipHiddenThenSetToRequired_secondRowAddsPostalCodeAndAdjustsMargin() {
  assertEquals(View.GONE, mNoZipGroup.postalCodeInputLayout.getVisibility());
  mNoZipCardMultilineWidget.setShouldShowPostalCode(true);
  assertEquals(View.VISIBLE, mNoZipGroup.postalCodeInputLayout.getVisibility());
  int expectedMargin = mNoZipCardMultilineWidget.getResources()
      .getDimensionPixelSize(R.dimen.add_card_expiry_middle_margin);
  LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)
      mNoZipGroup.cvcInputLayout.getLayoutParams();
  assertEquals(expectedMargin, params.rightMargin);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
    assertEquals(expectedMargin, params.getMarginEnd());
  }
}

代码示例来源:origin: stripe/stripe-android

@Test
public void initView_whenZipRequiredThenSetToHidden_secondRowLosesPostalCodeAndAdjustsMargin() {
  assertEquals(View.VISIBLE, mFullGroup.postalCodeInputLayout.getVisibility());
  mCardMultilineWidget.setShouldShowPostalCode(false);
  assertEquals(View.GONE, mFullGroup.postalCodeInputLayout.getVisibility());
  LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)
      mFullGroup.cvcInputLayout.getLayoutParams();
  assertEquals(0, params.rightMargin);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
    assertEquals(0, params.getMarginEnd());
  }
}

相关文章