2014-03-27 29 views
0

我是Android的初学者。 。 我有一个应用程序,其中有不同的文本出现在不同的活动。在我的应用程序中,我需要此应用程序中的所有文本。我使用setText()方法设置了应用中的文本的60%。但仍有一些文字是可见的,但我不知道他们是如何显示这些文字的。在android中显示文本的方法是什么?

所以我想要的是,在android中的方法或任何其他方式,使我们能够在我们的活动中显示文本。

更多的澄清我展示ü应用的图像:

enter image description here

我需要知道这些文字是如何被设置。 。 如果列出用于设置文本的方法,将会很有帮助。

+0

你将不得不使用选择并指定单独绘制的Android:state_focused,机器人:state_pressed – playmaker420

回答

0

您可以通过java或xml在textview中显示文本,也可以使用canvas.drawText()。

这些是简单的两个......还有用于快速弹出文本的吐司,以及用按钮吐司的对话......有几种方法可以显示文本。上面的图片,是文本设置为标签,或ImageView的的src /背景的背景图像...

0

主要是你要显示文本的方法:

  1. 使用元素允许显示文本:Button,TextView

对于这些家伙,您通常会使用您可能已经知道的.setText设置器。

  1. 您可以显示图像或使用图像作为背景的元素:ImageView的,ImageButton的

的图像设置为一个对象,你会正常使用

  • 公众void setImageResource(int resId)
  • public void setImageBitmap(Bitmap bm)
  • public void setImageDrawable(Drawable drawable)

上面的按钮,大多可能被设置为图像。

对于显示出不同的图像用于不同的状态(在抽头上选择等)你必须在低于该ImageButton的的例子来定义像的那些属性:

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:state_pressed="true" 
      android:drawable="@drawable/button_pressed" /> <!-- pressed --> 
    <item android:state_focused="true" 
      android:drawable="@drawable/button_focused" /> <!-- focused --> 
    <item android:drawable="@drawable/button_normal" /> <!-- default --> 
</selector> 

的更多信息在:

http://developer.android.com/reference/android/widget/ImageView.html http://developer.android.com/reference/android/widget/ImageButton.html http://developer.android.com/reference/android/widget/TextView.html

相关问题