当前位置: 首页>>代码示例>>Java>>正文


Java FlexboxLayout.getHeight方法代码示例

本文整理汇总了Java中com.google.android.flexbox.FlexboxLayout.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java FlexboxLayout.getHeight方法的具体用法?Java FlexboxLayout.getHeight怎么用?Java FlexboxLayout.getHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.flexbox.FlexboxLayout的用法示例。


在下文中一共展示了FlexboxLayout.getHeight方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testAlignContent_stretch

import com.google.android.flexbox.FlexboxLayout; //导入方法依赖的package包/类
@Test
@FlakyTest(tolerance = TOLERANCE)
public void testAlignContent_stretch() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    mActivityRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            activity.setContentView(R.layout.activity_align_content_test);
        }
    });
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);

    assertThat(flexboxLayout.getAlignContent(), is(FlexboxLayout.ALIGN_CONTENT_STRETCH));
    onView(withId(R.id.text1)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text1)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isRightOf(withId(R.id.text1)));
    // the third TextView is wrapped to the next flex line
    onView(withId(R.id.text3)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text3)).check(isBelow(withId(R.id.text1)));
    onView(withId(R.id.text3)).check(isBelow(withId(R.id.text2)));

    TextView textView3 = (TextView) activity.findViewById(R.id.text3);
    int flexLineCrossSize = flexboxLayout.getHeight() / 2;
    // Two flex line's cross sizes are expanded to the half of the height of the FlexboxLayout.
    // The third textView's top should be aligned witht the second flex line.
    assertThat(textView3.getTop(), is(flexLineCrossSize));
}
 
开发者ID:canceel,项目名称:flexboxlayout,代码行数:29,代码来源:FlexboxAndroidTest.java

示例2: testAlignItems_stretch

import com.google.android.flexbox.FlexboxLayout; //导入方法依赖的package包/类
@Test
@FlakyTest(tolerance = TOLERANCE)
public void testAlignItems_stretch() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    mActivityRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            activity.setContentView(R.layout.activity_stretch_test);
        }
    });
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);

    assertThat(flexboxLayout.getAlignItems(), is(FlexboxLayout.ALIGN_ITEMS_STRETCH));
    onView(withId(R.id.text1)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text1)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isRightOf(withId(R.id.text1)));
    onView(withId(R.id.text3)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text3)).check(isBelow(withId(R.id.text1)));
    onView(withId(R.id.text3)).check(isBelow(withId(R.id.text2)));

    // There should be 2 flex lines in the layout with the given layout.
    int flexLineSize = flexboxLayout.getHeight() / 2;
    TextView textView1 = (TextView) activity.findViewById(R.id.text1);
    TextView textView2 = (TextView) activity.findViewById(R.id.text2);
    TextView textView3 = (TextView) activity.findViewById(R.id.text3);
    assertTrue(flexLineSize - 1 <= textView1.getHeight()
            && textView1.getHeight() <= flexLineSize + 1);
    assertTrue(flexLineSize - 1 <= textView2.getHeight() &&
            flexLineSize <= flexLineSize + 1);
    assertTrue(flexLineSize - 1 <= textView3.getHeight() &&
            textView3.getHeight() <= flexLineSize + 1);
}
 
开发者ID:canceel,项目名称:flexboxlayout,代码行数:34,代码来源:FlexboxAndroidTest.java

示例3: testAlignSelf_stretch

import com.google.android.flexbox.FlexboxLayout; //导入方法依赖的package包/类
@Test
@FlakyTest(tolerance = TOLERANCE)
public void testAlignSelf_stretch() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    mActivityRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            activity.setContentView(R.layout.activity_align_self_stretch_test);
        }
    });
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);

    onView(withId(R.id.text1)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text1)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isRightOf(withId(R.id.text1)));
    onView(withId(R.id.text3)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text3)).check(isBelow(withId(R.id.text1)));
    onView(withId(R.id.text3)).check(isBelow(withId(R.id.text2)));

    // There should be 2 flex lines in the layout with the given layout.
    // Only the first TextView's alignSelf is set to ALIGN_SELF_STRETCH
    int flexLineSize = flexboxLayout.getHeight() / 2;
    TextView textView1 = (TextView) activity.findViewById(R.id.text1);
    TextView textView2 = (TextView) activity.findViewById(R.id.text2);
    TextView textView3 = (TextView) activity.findViewById(R.id.text3);
    assertTrue(flexLineSize - 1 <= textView1.getHeight() &&
            textView1.getHeight() <= flexLineSize + 1);
    assertThat(textView2.getHeight(), not(flexLineSize));
    assertThat(textView3.getHeight(), not(flexLineSize));
}
 
开发者ID:canceel,项目名称:flexboxlayout,代码行数:32,代码来源:FlexboxAndroidTest.java

示例4: testAlignItems_flexStart

import com.google.android.flexbox.FlexboxLayout; //导入方法依赖的package包/类
@Test
@FlakyTest(tolerance = TOLERANCE)
public void testAlignItems_flexStart() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    mActivityRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            activity.setContentView(R.layout.activity_align_items_test);
        }
    });
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);

    assertThat(flexboxLayout.getAlignItems(), is(FlexboxLayout.ALIGN_ITEMS_FLEX_START));
    onView(withId(R.id.text1)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text1)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isRightOf(withId(R.id.text1)));
    onView(withId(R.id.text3)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text3)).check(isBelow(withId(R.id.text1)));
    onView(withId(R.id.text3)).check(isBelow(withId(R.id.text2)));

    // There should be 2 flex lines in the layout with the given layout.
    int flexLineSize = flexboxLayout.getHeight() / 2;
    TextView textView1 = (TextView) activity.findViewById(R.id.text1);
    TextView textView2 = (TextView) activity.findViewById(R.id.text2);
    TextView textView3 = (TextView) activity.findViewById(R.id.text3);
    assertThat(textView1.getHeight(), not(flexLineSize));
    assertThat(textView2.getHeight(), not(flexLineSize));
    assertThat(textView3.getHeight(), not(flexLineSize));
    assertTrue(flexLineSize - 1 <= textView3.getTop() &&
            textView3.getTop() <= flexLineSize + 1);
}
 
开发者ID:canceel,项目名称:flexboxlayout,代码行数:33,代码来源:FlexboxAndroidTest.java


注:本文中的com.google.android.flexbox.FlexboxLayout.getHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。