I'm not sure its only the "last line", but we have an app that has a TextView with fill_parent width, wrap_content height. Text is being put in there dynamically from the Java code. The last line of the text simply isn't showing up, even though there's plenty of space in the layout. Its inside of a fairly deep view hierarchy, so my guess is the measure logic in there is getting messed up, but its pretty frustrating. We need to guess how many lines are going to be in the text and set 'android:lines' accordingly to get it to work.
Anybody seen this? In the code, see id 'contentTextView' towards the bottom. If I take out the 'android:lines', the last line of text disappears.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/flag"
>
<include android:id="@+id/incHeader" layout="@layout/header"/>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView
android:layout_width="fill_parent"
android:layout_height="101dp"
android:background="@drawable/headershadow"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible"
android:layout_weight="1"/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="101dp"
android:background="@drawable/footershadow"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/gybcontentback"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<include android:id="@+id/gybHeaderInclude" layout="@layout/gybcontentheader"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#4f4f4f"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:lines="9"
android:id="@+id/contentTextView"/>
<ImageView
android:layout_marginTop="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/button_blue_rascal_button"
android:id="@+id/buttonMoreInfo"/>
</LinearLayout>
</FrameLayout>
<include android:id="@+id/incFooter" layout="@layout/menu"/>
</LinearLayout>
Java code. I'm populating the TextView with a standard Java string during onCreate.
@Override
protected String body()
{
return "Rascal Flatts and The Jason Foundation, Inc. are working together to prevent suicide.\n\n" +
"Your Battle Buddy (or family member) may need a friend.\n\n" +
"Take the pledge to B1.";
}
The base class calls that to get the actual text
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(contentView());
wireMenu();
TextView headerText = (TextView) findViewById(R.id.gybHeaderText);
if(headerText != null)
headerText.setText(header());
((TextView) findViewById(R.id.contentTextView)).setText(body()); // This is where the text is set
}
Anyway, I'm boiling it down. I'm cutting out parts to see what's left and still getting the same issue. I think I may have found the trigger, and a solution, but not the "cause".