chuross / expandable-layout Goto Github PK
View Code? Open in Web Editor NEWhttp://qiita.com/chuross/items/81328feff73f55f9022e
License: Apache License 2.0
http://qiita.com/chuross/items/81328feff73f55f9022e
License: Apache License 2.0
I am unable to set dynamic layout in your ExpandableLayout. Please send some thing so that I can implement it.
LinearLayout lllistcontener = (LinearLayout) view.findViewById(R.id.lllistcontener);
lllistcontener.removeAllViews();
LinearLayout parent = new LinearLayout(view.getContext());
parent.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
parent.setOrientation(LinearLayout.HORIZONTAL);
//children of parent linearlayout
ImageView iv = new ImageView(view.getContext());
iv.setBackgroundResource(R.drawable.prson);
LinearLayout layout2 = new LinearLayout(view.getContext());
layout2.setBackgroundColor(Color.parseColor("#d3d3d3"));
layout2.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
parent.setOrientation(LinearLayout.VERTICAL);
parent.addView(iv);
parent.addView(layout2);
//children of layout2 LinearLayout
TextView tv1 = new TextView(view.getContext());
tv1.setText("Sadadasdasd");
TextView tv2 = new TextView(view.getContext());
tv2.setText("Sadadasdasd");
TextView tv3 = new TextView(view.getContext());
tv3.setText("Sadadasdasd");
TextView tv4 = new TextView(view.getContext());
tv4.setText("Sadadasdasd");
layout2.addView(tv1);
layout2.addView(tv2);
layout2.addView(tv3);
layout2.addView(tv4);
lllistcontener.removeAllViews();
lllistcontener.addView(layout2);
/* ViewGroup.LayoutParams params = subcommentlist.getLayoutParams();
params.height = 800;
subcommentlist.setLayoutParams(params);
subcommentlist.requestLayout();*/
expandableLayout.setCollapseHeight(300);
expandableLayout.expand();
expandMap.put(position, true);
On first expand, the expandable layout does not show anything but after next click it will show the view.
Sample Code
`
ArrayList categorySubItemModels =
categoryMainItemModel.getCategorySubItemModelList();
subCategoryButtons = new ArrayList<>();
for (int i = 0; i < categorySubItemModels.size(); i++) {
CategorySubItemModel categorySub = categorySubItemModels.get(i);
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
AppCompatButton button = (AppCompatButton) layoutInflater.inflate(R.layout.row_category_button_item, null);
ConstraintLayout.LayoutParams lp = new ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.WRAP_CONTENT, ConstraintLayout.LayoutParams.WRAP_CONTENT);
int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,8,context.getResources().getDisplayMetrics());
lp.setMargins(0, 0, margin, margin);
button.setLayoutParams(lp);
button.setTag("tagSubButton" + i);
button.setText(categorySub.getSubCategoryName());
button.setOnClickListener(v -> {
clearActivatedSubCategoryBtn();
v.setActivated(true);
if (categorySub.getSubSubCategoryNameList() != null){
tvSubTitle.setText(categorySub.getSubCategoryName());
flSubSubCategoryBtnContainer.removeAllViews();
subSubCategoryButtons = new ArrayList<>();
for (int x = 0; x < categorySub.getSubSubCategoryNameList().size(); x++){
String subSubCategoryName = categorySub.getSubSubCategoryNameList().get(x);
LayoutInflater layoutInflaterSub = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
AppCompatButton buttonSub = (AppCompatButton) layoutInflaterSub.inflate(R.layout.row_category_button_item, null);
ConstraintLayout.LayoutParams lpSub = new ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.WRAP_CONTENT, ConstraintLayout.LayoutParams.WRAP_CONTENT);
int marginSub = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,8,context.getResources().getDisplayMetrics());
lpSub.setMargins(0, 0, marginSub, marginSub);
buttonSub.setLayoutParams(lpSub);
buttonSub.setTag("tagSubSubButton" + x);
buttonSub.setText(subSubCategoryName);
buttonSub.setOnClickListener(v2 -> {
clearActivatedSubSubCategoryBtn();
v2.setActivated(true);
});
flSubSubCategoryBtnContainer.addView(buttonSub);
subSubCategoryButtons.add(buttonSub);
}
elSubSubCategoryContainer.expand();
}
});
flSubCategoryBtnContainer.addView(button);
subCategoryButtons.add(button);
}`
i have a recyclerview that contains a list of expandable-layouts which contain each another recyclerview
and when i create the fragment it scrolls automatically:
i have set the recyclerviews to fixed size and removed all animators/animations still this happens
weirdly it happens only in release builds, in debug builds everything works perfectly fine, i'm using latest support library 27.1.0, build tools 27.0.3, gradle build tools 3.1.0, kotlin 1.2.31
any idea how i can fix this?
any help is highly appreciated
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.