如何使斜体 TextView 在 Eclipse 图形布局视图中工作?它甚至挂断了电脑

发布于 2025-01-06 08:51:50 字数 862 浏览 3 评论 0原文

在 Eclipse 中工作,我试图将一些斜体文本放到布局上。问题是,当我设置时 android:textStyle="italic",文本消失。 (内容的高度变为 0,整个 TextView 变得不可见。)粗体工作正常。我已经尝试了每种字体,但结果都是一样的。

在设备上,它以斜体显示,OK。但布局非常复杂,看不见的设计也变得非常复杂。

这里的TextView

     <TextView
          android:id="@+id/smallEpgNextProgramTime"
          android:layout_width="200dp"
          android:layout_height="wrap_content"
          android:maxLines="1"
          android:ellipsize="end"
          android:layout_margin="10dp"
          android:gravity="left|top"
          android:textSize="35dp"
          android:typeface="monospace"
          android:textStyle="italic"
          android:text="12:00-13:11"
    />      

Android版本是2.3.3。 Eclipse 版本是 2.6。

情况更糟。如果我将斜体留在那里,在将布局视图更改为图形并返回文本后,Eclipse 的运行速度会越来越慢,并且会挂起 PC。因此,我必须将其设置为布局中的“正常”并通过代码设置 textStyle。这是一个坏错误!

Working in Eclipse, I am trying to put some italics text onto a layout. The problem is, that when I am setting
android:textStyle="italic", the text disappears. (The height of content becomes 0 and the whole TextView becomes invisible.) Bold works OK. I have tried every typeface, but the result is the same.

On the device it shows itself in italics OK. But the layout is very complicated and its design without seeing it becomes very complicated, too.

Here is the TextView

     <TextView
          android:id="@+id/smallEpgNextProgramTime"
          android:layout_width="200dp"
          android:layout_height="wrap_content"
          android:maxLines="1"
          android:ellipsize="end"
          android:layout_margin="10dp"
          android:gravity="left|top"
          android:textSize="35dp"
          android:typeface="monospace"
          android:textStyle="italic"
          android:text="12:00-13:11"
    />      

Android version is 2.3.3. Eclipse version is 2.6.

It is even worse. If I leave italics there, after some changes of layout view to graphics and back to text, Eclipse works slower and slower and hangs up the PC. So, I have to put it as "normal" in layout and to set textStyle by code. A bad bug it is!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

半世晨晓 2025-01-13 08:51:50

我认为这是一个android平台问题。

请参阅问题 22867:使用斜体文本样式时布局预览不正确

它不会显示在布局的图形表示上,但在构建和运行应用程序时可以正常工作。

更新:
如果您想预览设计 xml 布局,则只需使用

android:typeface="serif"

android:textStyle="italic" 即可。文本将在图形布局编辑器中以斜体样式显示。

它仅适用于这种衬线字体

I think its an android platform issue.

Look at Issue 22867: Incorrect layout preview when ITALIC text style used

It doesn't show up on the layout's graphical representation but works correctly when you build and run the app.

Update:
If you want to preview for designing xml layout then just use

android:typeface="serif"

In this android:textStyle="italic" works. And text will displayed in italic style in graphical layout editor.

Its only works for this serif typeface.

梦忆晨望 2025-01-13 08:51:50
 you can use this 

 TextView txtView;
 txtView=(TextView)findViewById(R.id.smallEpgNextProgramTime);
 txtView.setText(Html.fromHtml("Restaurant <i><b>Hello</b></i>"));
 you can use this 

 TextView txtView;
 txtView=(TextView)findViewById(R.id.smallEpgNextProgramTime);
 txtView.setText(Html.fromHtml("Restaurant <i><b>Hello</b></i>"));
ま昔日黯然 2025-01-13 08:51:50

你写的内容是100%正确的,如果你想用代码编写,你可以使用这个..

            textView.setTypeface(null, Typeface.ITALIC);
            textView.setText(editText.getText().toString());

What u wrote is 100% correct if you want to write in code you can use this..

            textView.setTypeface(null, Typeface.ITALIC);
            textView.setText(editText.getText().toString());
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文