FlowTexView动态添加的文本出现在单行高度问题中

时间:2015-02-03 12:41:06

标签: android layout

我在我的项目lib文件夹中添加了flowtextview jar文件,当我在我的布局中手动添加它时,它工作得很好。

我需要动态地将flowtextview添加到我的LinearLayout并将动态文本和图像添加到其中。我可以添加文本和图像,但文本出现在sinle行,我喜欢它因为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);

flowtextview text display issue

1 个答案:

答案 0 :(得分:0)

最后我发现了这个问题,因为它是jar文件。它不是一个更新的。使用flowtextview作为库项目并将其添加到项目中或使用或Gradle:

编译'uk.co.deanwild:flowtextview:2.0.2@aar'