-1

I have searched around but couldn't find some useful tutorials to decorate the textview in android layout xml, well few of them are not decorating as well.

I got to know few things as:

  1. android:shadowColor
  2. android:shadowDx
  3. android:shadowDy
  4. android:shadowRadius
  5. android:textAppearance
  6. android:textStyle
  7. android:typeface
  8. android:textColorHighlight
  9. android:textColor

As per my understanding we can use above attributest to decorate the text view to look more attractive. But i am not sure how to use. I am new in android, please correct me if i'm wrong.

Thanks

Akhil Gupta
  • 187
  • 3
  • 13
  • Ys these are used to beautify text in textview. What do you want to know ? – Preetika Kaur Nov 12 '16 at 04:25
  • did you try this github example https://github.com/hanks-zyh/HTextView? – Muhammad Waleed Nov 12 '16 at 04:37
  • @Preetika yes exactly to beautify text. Can you give any possible combination values of above attribute values that looks nice & i can change values as per my requirement. – Akhil Gupta Nov 12 '16 at 04:43
  • @Java coder thanks i will check that example. – Akhil Gupta Nov 12 '16 at 04:44
  • You cannot use all attributes in one textview that will make reverse effect. Use only those which are required and you will get examples easily for this on google – Preetika Kaur Nov 12 '16 at 04:51
  • @Preetika my basic need is font size, some 3D shadow effect. – Akhil Gupta Nov 12 '16 at 04:52
  • Android by default don't provide you to set font via attribute you have to set pragmatically. If you need code I can post that as answer. Also Shadow is applicable on API 21 and above. Do you have any font which gives you 3D look with Shadow. Then set it programatically. For font size you need to use textSize attribute – Preetika Kaur Nov 12 '16 at 04:54
  • @Preetika Thanks but sorry to say it didn't helped. i was just looking for some example whatever makes text look good & finally i got it thanks for your help. I was expecting answer here instead instructions to search in google that i've already done. Because I believe in Stackoverflow we get short & easy answers. – Akhil Gupta Nov 12 '16 at 05:06
  • @Downvoters please ask if anything is not clear. – Akhil Gupta Nov 12 '16 at 05:06
  • @AkhilGupta its OK but you should know this that people here will help you if you will post some thing what you have tried so far otherwise they ll tell you to search on google. Also you are clearing this point that you want to set textsize and shadow in comments so people will not gonna read your comments .] – Preetika Kaur Nov 12 '16 at 05:10

3 Answers3

2

Try the Shadow effect

               <TextView android:id="@+id/txt_example1"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:textSize="14sp"
                  android:textStyle="bold"
                  android:textColor="@color/light_font"
                  android:shadowColor="@color/text_shadow"
                  android:shadowDx="1"
                  android:shadowDy="1"
                  android:shadowRadius="2" />
Community
  • 1
  • 1
Anuj J Pandey
  • 656
  • 1
  • 4
  • 17
0

you can also try gradient effect:-

XML code:-

<TextView
    android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:text="ramji"
    android:textColor="@android:color/black"
    android:textSize="60sp"
    android:textStyle="bold"/>

MainActivity.kt code

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
    val textView = findViewById<TextView>(R.id.text)
    val shader = LinearGradient(0f, 0f, 0f, textView.textSize, Color.RED, Color.BLUE, Shader.TileMode.CLAMP)
    textView.paint.shader = shader
}

}

0

you can also try background image for text:-

XML code:-

<TextView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:gravity="center"
    android:text="ramji"
    android:textColor="#000000"
    android:textSize="80sp"
    android:textStyle="bold"/>

MainActivity.kt code:-

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    val textView = findViewById<TextView>(R.id.text)
    val bitmap = BitmapFactory.decodeResource(resources, R.drawable.bg)
    val shader = BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT)
    textView.paint.shader = shader
 }
}