Comments (17)
Could you share the layout xml you are using (or code snippet if you set it from code)?
from flexbox-layout.
Please re-open it with your layout XML and the code snippet.
Thanks.
from flexbox-layout.
I have two childView in FlexboxLayout ,if i set one View gone ,FlexboxLayout invisible
from flexbox-layout.
<com.google.android.flexbox.FlexboxLayout
android:id="@+id/lay_marks"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/tv_movie_score"
app:flexDirection="row"
app:justifyContent="flex_start"
>
<TextView
android:id="@+id/tv_movie_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp4"
android:singleLine="true"
android:text="电影名称哈哈哈"
android:textColor="@color/black"
android:textSize="@dimen/tsize_title"
app:layout_flexShrink="1"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
app:layout_flexShrink="0">
<com.kokozu.widget.flat.FlatTextView
android:id="@+id/tv_mark_new"
style="@style/Widget.Flat.Mark.MovieNew"
android:layout_marginRight="@dimen/dp4"
android:singleLine="true"
/>
<com.kokozu.widget.flat.FlatTextView
android:id="@+id/tv_mark_3d"
style="@style/Widget.Flat.Mark.3DIMAX"
android:singleLine="true"
/>
</LinearLayout>
</com.google.android.flexbox.FlexboxLayout>
from flexbox-layout.
if (isNew) {
holder.tvMarkNew.setVisibility(View.VISIBLE);
} else {
holder.tvMarkNew.setVisibility(View.GONE);
}
if (is3D || isIMAX) {
StringBuilder imax3D = new StringBuilder();
holder.tvMark3d.setVisibility(View.VISIBLE);
if (isIMAX) {
imax3D.append("IMAX");
} else {
imax3D.append("3D");
}
holder.tvMark3d.setText(imax3D.toString());
} else {
holder.tvMark3d.setVisibility(View.GONE);
}
from flexbox-layout.
i must use LinearLayout package TextView
from flexbox-layout.
The top of your pasted layout xml is truncated. Could you paste the full layout xml?
I tried locally with the children views whose visibilities are gone and it worked fine.
Also please confirm the following.
- Please try showing your layout not within part of the ListView
- Before setting the visibility from the code, is the layout in question visible?
from flexbox-layout.
public class MyAdapter extends BaseAdapter {
private Context mContext;
public MyAdapter(Context context) {
mContext = context;
}
@Override
public int getCount() {
return 100;
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Holder holder;
if (convertView == null) {
convertView = LayoutInflater.from(mContext).inflate(R.layout.item, null);
holder = new Holder();
holder.tv = (TextView) convertView.findViewById(R.id.tv);
convertView.setTag(holder);
} else {
holder = (Holder) convertView.getTag();
}
if (position / 2 == 0) {
holder.tv.setVisibility(View.VISIBLE);
} else {
holder.tv.setVisibility(View.GONE);
}
return convertView;
}
private static class Holder {
private TextView tv;
}
}
from flexbox-layout.
from flexbox-layout.
Thanks. How was the following?
Please try showing your layout not within part of the ListView
Before setting the visibility from the code, is the layout in question visible?
from flexbox-layout.
public class MainActivity extends AppCompatActivity {
private ListView lv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lv = (ListView) findViewById(R.id.lv);
lv.setAdapter(new MyAdapter(this));
}
}
from flexbox-layout.
from flexbox-layout.
Could you try the following in your environment and see if you still see the invisible FlexboxLayout?
I didn't ask you to upload the code for your Activity.
Please try showing your layout not within part of the ListView
Before setting the visibility from the code, is the layout in question visible?
from flexbox-layout.
from flexbox-layout.
This bug also occurs if I put 5 TextView
controls inside the Flexbox layout and set the visibility to gone for 2 TextViews
. If I set 1 TextView
to gone, the flexbox remains visible.
What I have noticed is that if the TextView
s don't fit in the screen width, the Flexbox is visible.
The workaround was to put all the individual text views inside a linearlayout as @a251115100 have mentioned.
The bug can be reproduced with the following code:
<com.google.android.flexbox.FlexboxLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:flexDirection="row"
app:flexWrap="wrap"
app:justifyContent="center">
<TextView
android:id="@+id/text_view_correct_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:drawableLeft="@drawable/correct_pie_chart_icon"
android:drawablePadding="5dp"
android:text="@string/label_correct"
android:textColor="@color/color_text"
android:textSize="@dimen/generic_text_size" />
<TextView
android:id="@+id/text_view_skipped_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:drawableLeft="@drawable/skipped_pie_chart_icon"
android:drawablePadding="5dp"
android:text="@string/label_skipped"
android:textColor="@color/color_text"
android:textSize="@dimen/generic_text_size" />
<TextView
android:id="@+id/text_view_assisted_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dp"
android:drawableLeft="@drawable/assisted_pie_chart_icon"
android:drawablePadding="5dp"
android:text="@string/label_assisted"
android:textColor="@color/color_text"
android:textSize="@dimen/generic_text_size" />
<TextView
android:id="@+id/text_view_incorrect_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:drawableLeft="@drawable/incorrect_pic_chart_icon"
android:drawablePadding="5dp"
android:text="@string/label_incorrect"
android:textColor="@color/color_text"
android:textSize="@dimen/generic_text_size" />
<TextView
android:id="@+id/text_view_reported_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:drawableLeft="@drawable/reported_pie_chart_icon"
android:drawablePadding="5dp"
android:text="@string/label_reported"
android:textColor="@color/color_text"
android:textSize="@dimen/generic_text_size" />
</com.google.android.flexbox.FlexboxLayout>
from flexbox-layout.
Thanks for the clarification. I'll take a look.
from flexbox-layout.
I think I spot the issue.
It happens when the first TextView's visibility in the second flex line is "gone".
If so it should be fixed by #52.
from flexbox-layout.
Related Issues (20)
- Add gap attribute HOT 3
- Wrong placement
- FlexboxLayoutManager.computeScrollOffset(); It is wrong to be equal to 0 HOT 1
- [FE] page 분기처리
- RecycleView nests RecycleView, and the internal RecycleView uses FlexboxLayoutManager(context, FlexDirection.ROW, FlexWrap.WRAP), when the number of items is large, it cannot be displayed completely (for example, only 30 items are displayed for 50 items, and they are not displayed after exceeding one screen) HOT 4
- ComposeView in flexbox crashes, because it is not attached when measured
- FlexboxLayoutManager child item margin is wrong when flex-direction is column
- How can i use this library in jetpack compose HOT 2
- Flaxbaox layout
- Playground doesn't build in latest Android Studio Flamingo HOT 3
- FlexboxLayoutManager does not recycle views with Navgraph HOT 3
- Is there possible to set "needsToFill" not only mContext.getResources().getDisplayMetrics().heightPixels?
- java.lang.ArrayIndexOutOfBoundsException: length=10; index=-1 HOT 1
- FlexBoxLayoutManager with RecyclerView causes multiple items to refresh on calling notifyItemChanged
- First party support for Compose UI HOT 2
- Support for Constraints of Rows & Columns
- Setting flex box percent to zero behaves differently than in CSS
- Update your Play Core Maven dependency to an Android 14 compatible version! HOT 5
- FlexboxLayout with asymetric horizontal padding clips children for justifyContent flex_end
- [URGENT] Unable to download dependency from Maven - version 3.0.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flexbox-layout.