Jeff
Jeff

Reputation: 4146

wrap_content leaving extra height when wrapping @string

I've got a TextView with the height set to wrap_content - however, it's leaving a lot of extra space in my app.

The text from the textview is coming in from a @+string and it seems as though the wrap_content is setting it's height to the height of the string variable, not the actual text that's being inserted.

If I replace

            android:text="@+string/introGetStarted"

with

            android:text="Let's get started!"

then it seems to show the proper height and wraps just the text.

Am I missing something?

My full TextView, for reference:

   <TextView
        android:id="@+id/textViewTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/d15"
        android:layout_marginRight="@dimen/d30"
        android:layout_marginTop="@dimen/d25"
        android:lineSpacingExtra="-10sp"
        android:text="@string/introGetStarted"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textSize="@dimen/d70" />

Upvotes: 0

Views: 898

Answers (2)

Jeff
Jeff

Reputation: 4146

I actually found the answer, it was due to a newline character coming out of the strings.xml file itself.

Upvotes: 1

Yaroslav Mytkalyk
Yaroslav Mytkalyk

Reputation: 17115

Your are referencing string resources wrong. Remove the plus

android:text="@string/introGetStarted"

@+string/ means something like adding new string resource with name "introGetStarted", while @string/introGetStarted means referencing existing resource "introGetStarted"

Upvotes: 1

Related Questions