首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >FlowTexView动态添加的文本出现在单行高度问题中

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

Stack Overflow用户
提问于 2015-02-03 20:41:06
回答 1查看 91关注 0票数 0

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

我需要动态地将流文本视图添加到我的LinearLayout中,并动态地向其中添加文本和图像。我可以添加文本和图像,但文本显示在单行中,我认为这是因为flowtexview高度设置问题。

请检查附件中的图像,您可以正确地看到问题。

用于添加动态视图的代码如下:

代码语言:javascript
复制
            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);

EN

回答 1

Stack Overflow用户

发布于 2015-02-04 19:42:26

最后我找到了问题所在,这是由于jar文件的原因。这不是最新的。使用flowtextview作为库项目,并将其添加到您的项目中,或者使用或Gradle:

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28299225

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档