android.text.Layout.getAlignment()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(136)

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

Layout.getAlignment介绍

暂无

代码示例

代码示例来源:origin: sjwall/MaterialTapTargetPrompt

result = layout.getAlignment() == Layout.Alignment.ALIGN_OPPOSITE;
if (!result && layout.getAlignment() == Layout.Alignment.ALIGN_NORMAL
    && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
        .getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
else if (layout.getAlignment() == Layout.Alignment.ALIGN_OPPOSITE && textIsRtl)

代码示例来源:origin: sjwall/MaterialTapTargetPrompt

@Test
public void testIsRtlFirstCharacterRtl()
{
  final Layout layout = mock(Layout.class);
  when(layout.isRtlCharAt(0)).thenReturn(true);
  when(layout.getAlignment()).thenReturn(Layout.Alignment.ALIGN_NORMAL);
  assertTrue(PromptUtils.isRtlText(layout, null));
}

代码示例来源:origin: sjwall/MaterialTapTargetPrompt

@Test
public void testIsRtlFirstCharacterRtlOpposite()
{
  final Layout layout = mock(Layout.class);
  when(layout.isRtlCharAt(0)).thenReturn(true);
  when(layout.getAlignment()).thenReturn(Layout.Alignment.ALIGN_OPPOSITE);
  assertFalse(PromptUtils.isRtlText(layout, null));
}

代码示例来源:origin: sjwall/MaterialTapTargetPrompt

@Test
public void testIsRtlFirstCharacterNotRtlOpposite()
{
  final Layout layout = mock(Layout.class);
  when(layout.isRtlCharAt(0)).thenReturn(false);
  when(layout.getAlignment()).thenReturn(Layout.Alignment.ALIGN_OPPOSITE);
  assertTrue(PromptUtils.isRtlText(layout, null));
}

代码示例来源:origin: sjwall/MaterialTapTargetPrompt

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
@Test
public void testIsRtlFirstCharacterNotRtlOppositePreJellyBeanMR1()
{
  ReflectionHelpers.setStaticField(Build.VERSION.class, "SDK_INT", Build.VERSION_CODES.JELLY_BEAN_MR1);
  final Resources resources = mock(Resources.class);
  final Configuration configuration = mock(Configuration.class);
  when(resources.getConfiguration()).thenReturn(configuration);
  when(configuration.getLayoutDirection()).thenReturn(View.LAYOUT_DIRECTION_RTL);
  final Layout layout = mock(Layout.class);
  when(layout.isRtlCharAt(0)).thenReturn(false);
  when(layout.getAlignment()).thenReturn(Layout.Alignment.ALIGN_NORMAL);
  assertTrue(PromptUtils.isRtlText(layout, resources));
}

代码示例来源:origin: sjwall/MaterialTapTargetPrompt

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
@Test
public void testIsRtlFirstCharacterNotRtl()
{
  ReflectionHelpers.setStaticField(Build.VERSION.class, "SDK_INT", Build.VERSION_CODES.JELLY_BEAN_MR1);
  final Resources resources = mock(Resources.class);
  final Configuration configuration = mock(Configuration.class);
  when(resources.getConfiguration()).thenReturn(configuration);
  when(configuration.getLayoutDirection()).thenReturn(View.LAYOUT_DIRECTION_LTR);
  final Layout layout = mock(Layout.class);
  when(layout.isRtlCharAt(0)).thenReturn(false);
  when(layout.getAlignment()).thenReturn(Layout.Alignment.ALIGN_NORMAL);
  assertFalse(PromptUtils.isRtlText(layout, resources));
}

代码示例来源:origin: sjwall/MaterialTapTargetPrompt

@Test
public void testIsRtlFirstCharacterNotRtlNotOppositePreJellyBeanMR1()
{
  ReflectionHelpers.setStaticField(Build.VERSION.class, "SDK_INT", Build.VERSION_CODES.JELLY_BEAN_MR1);
  final Layout layout = mock(Layout.class);
  when(layout.isRtlCharAt(0)).thenReturn(false);
  when(layout.getAlignment()).thenReturn(Layout.Alignment.ALIGN_CENTER);
  assertFalse(PromptUtils.isRtlText(layout, null));
}

代码示例来源:origin: sjwall/MaterialTapTargetPrompt

@Test
public void testIsRtlFirstCharacterNotRtlPreJellyBeanMR1()
{
  ReflectionHelpers.setStaticField(Build.VERSION.class, "SDK_INT", Build.VERSION_CODES.JELLY_BEAN);
  final Layout layout = mock(Layout.class);
  when(layout.isRtlCharAt(0)).thenReturn(false);
  when(layout.getAlignment()).thenReturn(Layout.Alignment.ALIGN_NORMAL);
  assertFalse(PromptUtils.isRtlText(layout, null));
}

代码示例来源:origin: sjwall/MaterialTapTargetPrompt

@Test
public void testIsRtlPreIceCreamSandwich()
{
  ReflectionHelpers.setStaticField(Build.VERSION.class, "SDK_INT", Build.VERSION_CODES.HONEYCOMB_MR2);
  final Layout layout = mock(Layout.class);
  when(layout.getAlignment()).thenReturn(Layout.Alignment.ALIGN_NORMAL);
  assertFalse(PromptUtils.isRtlText(layout, null));
}

代码示例来源:origin: sjwall/MaterialTapTargetPrompt

@Override
  void createTextLayout(@NonNull final PromptOptions options, final float maxWidth, final float alphaModifier)
  {
    super.createTextLayout(options, maxWidth, alphaModifier);
    if (mPrimaryTextLayout != null)
    {
      mPrimaryTextLayout = spy(mPrimaryTextLayout);
      when(mPrimaryTextLayout.getLineWidth(0)).thenReturn(mMaxTextWidth);
      when(mPrimaryTextLayout.getHeight()).thenReturn(200);
      if (mRtl)
      {
        when(mPrimaryTextLayout.getAlignment()).thenReturn(Layout.Alignment.ALIGN_OPPOSITE);
      }
    }
    if (mSecondaryTextLayout != null)
    {
      mSecondaryTextLayout = spy(mSecondaryTextLayout);
      when(mSecondaryTextLayout.getLineWidth(0)).thenReturn(mMaxTextWidth);
      when(mSecondaryTextLayout.getHeight()).thenReturn(200);
      if (mRtl)
      {
        when(mSecondaryTextLayout.getAlignment()).thenReturn(Layout.Alignment.ALIGN_OPPOSITE);
      }
    }
  }
}

代码示例来源:origin: sjwall/MaterialTapTargetPrompt

@Test
public void testIsRtlPreIceCreamSandwichOpposite()
{
  ReflectionHelpers.setStaticField(Build.VERSION.class, "SDK_INT", Build.VERSION_CODES.HONEYCOMB_MR2);
  final Layout layout = mock(Layout.class);
  when(layout.getAlignment()).thenReturn(Layout.Alignment.ALIGN_OPPOSITE);
  assertTrue(PromptUtils.isRtlText(layout, null));
}

代码示例来源:origin: sjwall/MaterialTapTargetPrompt

@Test
public void testIsRtlPreIceCreamSandwichCentre()
{
  ReflectionHelpers.setStaticField(Build.VERSION.class, "SDK_INT", Build.VERSION_CODES.HONEYCOMB_MR2);
  final Layout layout = mock(Layout.class);
  when(layout.getAlignment()).thenReturn(Layout.Alignment.ALIGN_CENTER);
  assertFalse(PromptUtils.isRtlText(layout, null));
}

代码示例来源:origin: facebook/TextLayoutBuilder

@Test
public void testSetAlignment() {
 mLayout = mBuilder.setAlignment(Layout.Alignment.ALIGN_CENTER).build();
 assertEquals(mBuilder.getAlignment(), Layout.Alignment.ALIGN_CENTER);
 assertEquals(mLayout.getAlignment(), Layout.Alignment.ALIGN_CENTER);
}

代码示例来源:origin: stackoverflow.com

final Layout originalLayout = super.getLayout();
 final Layout layout = new StaticLayout(text, mStrokePaint,
 originalLayout.getWidth(), originalLayout.getAlignment(),
 originalLayout.getSpacingMultiplier(), originalLayout.getSpacingAdd(), true);
 canvas.save();
 canvas.translate( layout.getLineWidth(0) * 0.5f, 0.0f );
 layout.draw(canvas);
 canvas.restore();

代码示例来源:origin: shazam/reflow-animator

private static Layout createUnrestrictedLayout(@Nonnull TextView view) {
  CharSequence text = view.getText();
  Layout layout = view.getLayout();
  TextPaint paint = layout.getPaint();
  if (SDK_INT >= M) {
    return StaticLayout.Builder
        .obtain(text, 0, text.length(), layout.getPaint(), layout.getWidth())
        .setAlignment(layout.getAlignment())
        .setLineSpacing(view.getLineSpacingExtra(), view.getLineSpacingMultiplier())
        .setIncludePad(view.getIncludeFontPadding())
        .setBreakStrategy(view.getBreakStrategy())
        .setHyphenationFrequency(view.getHyphenationFrequency())
        .build();
  } else {
    return new StaticLayout(
        text,
        paint,
        text.length(),
        layout.getAlignment(),
        view.getLineSpacingMultiplier(),
        view.getLineSpacingExtra(),
        view.getIncludeFontPadding());
  }
}

相关文章