Android text in drawable layer-list

23,927

One way to add Texts in your drawable layer-list is by creating a png file of the text and adding it using bitmap. Here is one example of it.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:drawable="@drawable/background"/>

    <item android:bottom="150dp">
        <bitmap
            android:gravity="center"
            android:src="@drawable/logo"/>


    </item>
    <item android:top="60dp">
        <bitmap
            android:gravity="center"
            android:tint="@android:color/white"
            android:src="@drawable/text"/>
    </item>
</layer-list>
Share:
23,927
Katedral Pillon
Author by

Katedral Pillon

Updated on June 05, 2020

Comments

  • Katedral Pillon
    Katedral Pillon almost 4 years

    I am trying to implement splash screen without any extra activities, using theme call in the manifest file's <activity/> tag.

    In my styles.xml

    <style name="splashTheme" parent="AppTheme">
            <item name="android:windowBackground">@drawable/splash</item>
    </style>
    

    here the drawable file splash.xml uses layer-list How do I add text to this layer list?

  • ahbou
    ahbou over 7 years
    while this might be a good hack, it doesn't allow solve the issue of putting text inside a layer-list