我已经在我的项目lib文件夹中添加了flowtextview jar文件,当我将它添加到我的布局手册中时,它工作得很好。
我需要动态地将流文本视图添加到我的LinearLayout中,并动态地向其中添加文本和图像。我可以添加文本和图像,但文本显示在单行中,我认为这是因为flowtexview高度设置问题。
请检查附件中的图像,您可以正确地看到问题。
用于添加动态视图的代码如下:
contentHolder = (LinearLayout)rootview.findViewById(R.id.contentOuter);
//add LayoutParams
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
//params.setMargins(10, 20, 10, 20); // llp.setMargins(left, top, right, bottom);
contentHolder.setOrientation(LinearLayout.VERTICAL);
ftv = new FlowTextView(getActivity());
FlowTextView.LayoutParams fp = new FlowTextView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
fp.setMargins(0, 10, 0, 10);
ftv.setLayoutParams(params);
ftv.setId(110);
ftv.setText("Currently it is placing that image as the background to the view and not the actual image in it.Currently it is placing that image as the background to the view and not the actual image in it.Currently it is placing that image as the background to the view and not the actual image in it..");
ImageView im = new ImageView(getActivity());
im.setBackgroundResource(R.drawable.av1);
im.setId(5);
RelativeLayout rt = new RelativeLayout(getActivity());
RelativeLayout.LayoutParams rparams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
rparams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
rparams.setMargins(0, 10, 0, 10);
rt.setLayoutParams(rparams);
rt.addView(im);
ftv.addView(rt);
ftv.invalidate();
//add the textView and the Button to LinearLayout
contentHolder.addView(ftv);

发布于 2015-02-04 19:42:26
最后我找到了问题所在,这是由于jar文件的原因。这不是最新的。使用flowtextview作为库项目,并将其添加到您的项目中,或者使用或Gradle:
编译'uk.co.deanwild:flowtextview:2.0.2@aar‘
https://stackoverflow.com/questions/28299225
复制相似问题