草庐IT

textView2

全部标签

android - 我想为 android 中的 TextView 连接两个字符串,Data Binding Api

我正在使用DataBindingApi在android布局中设置View。这是我的布局。layout.xml我希望TextView显示HelloUserName。如何使用数据绑定(bind)api实现这一点。 最佳答案 用重音(`)连接它android:text="@{`Hello`+user.firstName}"/>您可以通过多种方式连接它,请在此处查看concat-two-strings-in-textview-using-databinding 关于android-我想为andr

android - 我想为 android 中的 TextView 连接两个字符串,Data Binding Api

我正在使用DataBindingApi在android布局中设置View。这是我的布局。layout.xml我希望TextView显示HelloUserName。如何使用数据绑定(bind)api实现这一点。 最佳答案 用重音(`)连接它android:text="@{`Hello`+user.firstName}"/>您可以通过多种方式连接它,请在此处查看concat-two-strings-in-textview-using-databinding 关于android-我想为andr

android - 如何以编程方式设置 TextView 的边距?

TextViewtv1=newTextView(this);tv1.setPadding(5,0,5,0);tv1.setLayoutParams(newLayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.MATCH_PARENT));tv1.setBackgroundColor(Color.parseColor("#0099cc"));tv1.setTextColor(Color.WHITE);tv1.setTextSize(11);tv1.setGravity(Gravity.LEFT|Gravity.BOTTOM);tv1.se

android - 如何以编程方式设置 TextView 的边距?

TextViewtv1=newTextView(this);tv1.setPadding(5,0,5,0);tv1.setLayoutParams(newLayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.MATCH_PARENT));tv1.setBackgroundColor(Color.parseColor("#0099cc"));tv1.setTextColor(Color.WHITE);tv1.setTextSize(11);tv1.setGravity(Gravity.LEFT|Gravity.BOTTOM);tv1.se

android - 如何在同一部分文本上的 TextView 文本上设置多个跨度?

假设我有下一个文本:HellostackOverflow我希望将第二个单词设置为RelativeSizeSpan(设置相对字体大小)和TextAppearanceSpan(设置文本的颜色),如何合并它们?我只知道我可以选择其中一个,例如使用下一个代码:finalSpannableStringtextToShow=newSpannableString("HellostackOverflow");textToShow.setSpan(newRelativeSizeSpan(1.5f),textToShow.length()-"stackOverflow".length(),textToSh

android - 如何在同一部分文本上的 TextView 文本上设置多个跨度?

假设我有下一个文本:HellostackOverflow我希望将第二个单词设置为RelativeSizeSpan(设置相对字体大小)和TextAppearanceSpan(设置文本的颜色),如何合并它们?我只知道我可以选择其中一个,例如使用下一个代码:finalSpannableStringtextToShow=newSpannableString("HellostackOverflow");textToShow.setSpan(newRelativeSizeSpan(1.5f),textToShow.length()-"stackOverflow".length(),textToSh

android - 如何获取TextView的行数?

我想获取一个TextView的行数textView.setText("Testline1Testline2Testline3Testline4Testline5.............")textView.getLineCount();总是返回zero那我也试过了:ViewTreeObservervto=this.textView.getViewTreeObserver();vto.addOnGlobalLayoutListener(newOnGlobalLayoutListener(){@OverridepublicvoidonGlobalLayout(){ViewTreeObse

android - 如何获取TextView的行数?

我想获取一个TextView的行数textView.setText("Testline1Testline2Testline3Testline4Testline5.............")textView.getLineCount();总是返回zero那我也试过了:ViewTreeObservervto=this.textView.getViewTreeObserver();vto.addOnGlobalLayoutListener(newOnGlobalLayoutListener(){@OverridepublicvoidonGlobalLayout(){ViewTreeObse

android - 如何获取 TextView 的文本颜色?

在给定的代码中lbl[0].getTextColor()给出错误,但我不知道如何在java文件中获取textview的文本颜色,请帮助我。publicvoidangry(Viewv){if(lbl[0].getTextColor()==Color.BLACK)lbl[0].setTextColor(Color.RED);if(lbl[0].getTextColor()==Color.RED)lbl[0].setTextColor(Color.BLACK);}谢谢。 最佳答案 使用这个textView.getCurrentTextCo

android - 如何获取 TextView 的文本颜色?

在给定的代码中lbl[0].getTextColor()给出错误,但我不知道如何在java文件中获取textview的文本颜色,请帮助我。publicvoidangry(Viewv){if(lbl[0].getTextColor()==Color.BLACK)lbl[0].setTextColor(Color.RED);if(lbl[0].getTextColor()==Color.RED)lbl[0].setTextColor(Color.BLACK);}谢谢。 最佳答案 使用这个textView.getCurrentTextCo