I reached above the specified interface. Created a horizontal scroll view and one linear layout with a horizontal orientation. Following at runtime depending on the No of Strings in the array, I added a textual representation to the Linear Layout that it is. The code is as follows.
private void addTextView(ArrayList<String> list,String whichLayout){
for (int i = 0; i < list.size(); i++) {
TextView textView = new TextView(getActivity());
Spannable spValue = new SpannableString(list.get(i).toString());
textView.setText(customeSpan.getRequiredFontTypeToText(spValue, tfHintTxtValue));
textView.setTextSize(12.0f);
textView.setTextColor(getResources().getColor(R.color.black));
textView.setBackgroundResource(R.drawable.red_solid_background);
LinearLayout.LayoutParams lllp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lllp.setMargins(0, 2, 10, 0);
textView.setLayoutParams(lllp);
if(whichLayout.equalsIgnoreCase("hieghtWieght")){
((LinearLayout) heightWieghtLinearLayout).addView(textView);
}else if(whichLayout.equalsIgnoreCase("bodyType")){
((LinearLayout) bodyTypeLinearLayout).addView(textView);
}else if(whichLayout.equalsIgnoreCase("eyeHair")){
((LinearLayout) eyeHairColorLinearLayout).addView(textView);
}else if(whichLayout.equalsIgnoreCase("bestFeatures")){
((LinearLayout) bestFeaturesLinearLayout).addView(textView);
}else if(whichLayout.equalsIgnoreCase("personalStyle")){
((LinearLayout) personalStyleLinearLayout).addView(textView);
}else if(whichLayout.equalsIgnoreCase("zodiacSign")){
((LinearLayout) zodizcSignLinearLayout).addView(textView);
}else if(whichLayout.equalsIgnoreCase("personalityTraits")){
((LinearLayout) personalityLinearLayout).addView(textView);
}
}
}
source
share