We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If I set the margin by code instead of xml, there is no margin show up. here is the code. searchHistory is the type of FlowLayout
private void loadSearchHistoryFromDB() { ArrayList<String> keyWords = myDatabase.getAllBeitieSearchHistory(); for (final String keyword: keyWords) { TextView textView = new TextView(getActivity()); textView.setText(keyword); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); textView.setBackgroundResource(R.drawable.tag_text); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { searchBeitieInDB(keyword); } }); ViewGroup.MarginLayoutParams lp = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lp.leftMargin = 15; lp.rightMargin = 15; lp.topMargin = 15; lp.bottomMargin = 15; searchHistory.addView(textView, lp); } }
The text was updated successfully, but these errors were encountered:
@zdd the margin value will be ignored when you add child view with ViewGroup.MarginLayoutParams instead of FlowLayout.LayoutParams.
ViewGroup.MarginLayoutParams
FlowLayout.LayoutParams
The following code can solve the problem:
FlowLayout.LayoutParams lp = new FlowLayout.LayoutParams(FlowLayout.LayoutParams.WRAP_CONTENT, FlowLayout.LayoutParams.WRAP_CONTENT);
Sorry, something went wrong.
@yisizhu520 thanks
blazsolar
No branches or pull requests
If I set the margin by code instead of xml, there is no margin show up. here is the code. searchHistory is the type of FlowLayout
The text was updated successfully, but these errors were encountered: