Ate*_*res 4 android android-flexboxlayout
我 flexbox-layout包含TextView具有以下属性的内容:
app:layout_wrapBefore="true"
Run Code Online (Sandbox Code Playgroud)
但我需要以false编程方式将其设置为!
关于如何做到这一点的任何想法?
xml,如果需要的话!
<com.google.android.flexbox.FlexboxLayout
android:id="@+id/flexboxlayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
app:alignContent="stretch"
app:alignItems="stretch"
app:flexWrap="wrap"
app:justifyContent="flex_end">
<TextView
android:id="@+id/mainText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="07:22 PM"
android:textSize="12sp"
app:layout_alignSelf="center"
app:layout_wrapBefore="true" />
</com.google.android.flexbox.FlexboxLayout>
Run Code Online (Sandbox Code Playgroud)
您必须使用setWrapBefore方法,如其 LayoutParams 中所述,并再次将这些布局参数设置为 TextVuew。
TextView mainTextView = findViewById(R.id.mainText); // or get it as you should
FlexboxLayout.LayoutParams lp = (FlexboxLayout.LayoutParams) mainTextView.getLayoutParams();
lp.setWrapBefore(false);
mainTextView.setLayoutParams(lp);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1363 次 |
| 最近记录: |