Android text in drawable layer-list
Asked Answered
E

1

41

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?

Episcopate answered 2/7, 2016 at 16:0 Comment(5)
I think this post answers your question: #23300052Dichroism
Hmm, though you could do it with vector drawables according to this post: #22850931 I know that the new support library is backporting vector drawables for pre 21 devices but I am not certain if it will support this. It's worth a little investigation though if you are deadset on having a layer with text!Dichroism
Just for the record, the first link does not even come close to addressing my problem. For Splash screens, my practice is to not use a layout file but to instead set the background in the theme.Episcopate
I gotcha and thanks for pointing that out, I was focusing solely on the part of your question about putting text in a layer-list drawable. I think the second link should be able to help you out in that case if you are using support library 23.2.0. medium.com/@chrisbanes/…Dichroism
I ended up converting text into a vector drawable and then using as a bitmap in one of the layersLandsknecht
A
9

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>
Adolescent answered 4/12, 2016 at 11:27 Comment(1)
while this might be a good hack, it doesn't allow solve the issue of putting text inside a layer-listSumerlin

© 2022 - 2024 — McMap. All rights reserved.