按钮don';迁移到Android Studio后无法工作
Muy buid.graddle配置为:按钮don';迁移到Android Studio后无法工作,android,html,button,android-studio,spannable,Android,Html,Button,Android Studio,Spannable,Muy buid.graddle配置为: SpannableStringBuilder cs = new SpannableStringBuilder("* ^"); cs.setSpan(new SuperscriptSpan(), 1, 4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); cs.setSpan(new RelativeSizeSpan((float) 0.50), 1, 4, Spannable.SPAN_EXCLUSIVE_EXCLUS
SpannableStringBuilder cs = new SpannableStringBuilder("* ^");
cs.setSpan(new SuperscriptSpan(), 1, 4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
cs.setSpan(new RelativeSizeSpan((float) 0.50), 1, 4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
MyButton.setText(cs);
LinearLayout ly = new LinearLayout(this);
Button b = new Button(this);
b.setText(Html.fromHtml("* <small><sup>^</sup></small>"));
ly.addView(b);
TextView tv = new TextView(this);
tv.setText(Html.fromHtml("* <small><sup>^</sup></small>"));
ly.addView(tv);
setContentView(ly);
谢谢你的帮助 问题不在于迁移。我创建了一个新程序,其中包括:
android {
compileSdkVersion 18
buildToolsVersion "21.1.2"
谢谢你的帮助 试试这个…
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
Button byButton=新按钮(此按钮);
byButton.setText(Html.fromHtml(“*^”);
您不应该使用3,4而不是1,4吗?我使用的是html模式。问题不在于编程,而是迁移到Android Studio!它是相同的设备api版本吗,如果是,是哪一个?在所有设备上都是相同的…不可能,imho,您看到的可能不是Html版本,而是SpannableStringBuilder,将1更改为2并运行again@pskink简单的html标记的问题也是如此:b.setText(html.fromHtml(“a”));解决方案:添加b.setAllCaps(假);说明:
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
Button byButton = new Button(this);
byButton.setText(Html.fromHtml(" * <small><sup> ^ </sup></small>"));