草庐IT

TextView_Roboto

全部标签

android - 如何确定 TextView 中可见的行数?

如何获取TextView的可见部分显示多少行?我使用文本,在每个屏幕分辨率上都没有完全放置在TextView中。Strings="verybigtext"TextViewlogText=(TextView)view.findViewById(R.id.logs_text);logText.setText(s); 最佳答案 android.text.Layout包含此信息及更多信息。使用textView.getLayout().getLineCount()获取行数。请注意,如果在布局过程完成之前调用getLayout()可能会返回nu

安卓 TextView : Getting "W/StaticLayout: maxLineHeight should not be -1. maxLines:1 lineCount:1" when setting text

我根据计时器每0.5秒在TextView上设置一些文本。每次,当计时器运行并设置文本时,我都会在控制台中收到此警告消息。W/StaticLayout:maxLineHeightshouldnotbe-1.maxLines:1lineCount:1XML代码:Java代码:publicvoidsetProgress(){//setProgress()calledevery0.5seconds//HardcodedtextmTimeText.setText("0:05");} 最佳答案 回答我自己的问题。注意我有两个TextView的t

安卓 TextView : Getting "W/StaticLayout: maxLineHeight should not be -1. maxLines:1 lineCount:1" when setting text

我根据计时器每0.5秒在TextView上设置一些文本。每次,当计时器运行并设置文本时,我都会在控制台中收到此警告消息。W/StaticLayout:maxLineHeightshouldnotbe-1.maxLines:1lineCount:1XML代码:Java代码:publicvoidsetProgress(){//setProgress()calledevery0.5seconds//HardcodedtextmTimeText.setText("0:05");} 最佳答案 回答我自己的问题。注意我有两个TextView的t

java - Android TextView 计时器

对于我的Android应用程序,有一个计时器可以测量经过了多少时间。每100毫秒,我都会用一些文本更新我的TextView,例如“分数:10时间:100.10秒”。但是,我发现TextView只更新前几次。该应用程序仍然非常敏感,但标签不会更新。我试图调用.invalidate(),但它仍然不起作用。我不知道是否有某种方法可以解决这个问题,或者使用更好的小部件。这是我的代码示例:floatseconds;java.util.Timergametimer;voidupdatecount(){TextViewt=(TextView)findViewById(R.id.topscore);t

java - Android TextView 计时器

对于我的Android应用程序,有一个计时器可以测量经过了多少时间。每100毫秒,我都会用一些文本更新我的TextView,例如“分数:10时间:100.10秒”。但是,我发现TextView只更新前几次。该应用程序仍然非常敏感,但标签不会更新。我试图调用.invalidate(),但它仍然不起作用。我不知道是否有某种方法可以解决这个问题,或者使用更好的小部件。这是我的代码示例:floatseconds;java.util.Timergametimer;voidupdatecount(){TextViewt=(TextView)findViewById(R.id.topscore);t

android - 在 TextView/EditText 上使用 "android:textAppearance"失败,但 "style"有效

这是一个XML中的示例TextView,它将正确地将样式TextContactContactName应用于TextView。现在,我要在这个元素上设置其他一些与文本无关的东西。因此,我尝试移动TextContactContactName并通过“android:textAppearance”应用它不幸的是,没有应用文本格式。这是样式(存储在res/values/styles-text.xml中)的样子:24sp#333333#ffffff011我使用textAppearance标签有错吗?我在Android2.2-HTCDesire上进行了测试。 最佳答案

android - 在 TextView/EditText 上使用 "android:textAppearance"失败,但 "style"有效

这是一个XML中的示例TextView,它将正确地将样式TextContactContactName应用于TextView。现在,我要在这个元素上设置其他一些与文本无关的东西。因此,我尝试移动TextContactContactName并通过“android:textAppearance”应用它不幸的是,没有应用文本格式。这是样式(存储在res/values/styles-text.xml中)的样子:24sp#333333#ffffff011我使用textAppearance标签有错吗?我在Android2.2-HTCDesire上进行了测试。 最佳答案

Android::findViewByID - 如何通过另一个 UI 元素的监听器获取 TextView 的 View ?

这将是一个有点蹩脚的问题。我有以下代码:..............publicvoidonCreate(Bundlebundle){super.onCreate(bundle);this.setContentView(R.layout.main2);Buttonbnt=(Button)this.findViewById(R.id.browser);bnt.setOnClickListener(newButtonListener());}..............classButtonListenerimplementsandroid.view.View.OnClickListene

Android::findViewByID - 如何通过另一个 UI 元素的监听器获取 TextView 的 View ?

这将是一个有点蹩脚的问题。我有以下代码:..............publicvoidonCreate(Bundlebundle){super.onCreate(bundle);this.setContentView(R.layout.main2);Buttonbnt=(Button)this.findViewById(R.id.browser);bnt.setOnClickListener(newButtonListener());}..............classButtonListenerimplementsandroid.view.View.OnClickListene

android - 在 TextView 中使用制表符/制表符

我希望在我调用setText的行中使用一些制表符if(id==R.id.radioButton1){title.setText(numbertext.getText()+"Grams");在这种情况下,我想在numbertekst.getText()和克之间切换。输出是带有值的简单行的一部分。但是由于我找不到选项卡,所以该行有点难看。我知道我可以使用多个文本字段甚至一个表格。但由于我已经有很多代码,我还不想那样做。我尝试了Java的方式加上\t,但这似乎不起作用。任何帮助将不胜感激。 最佳答案 您应该在文本中添加制表符,但\t在se