Whenever the android:layout_gravity="bottom"
attribute is set on the style xml sheet, the text seems to be cut off at the top, and extra blank lines appear at the bottom. I have set this in order to auto-scroll to the bottom when there is too much text to display. This is hosted in a DialogFragment
.
Note: the text being displayed is from TextView.setText(Html.fromHtml())
, with newlines being done as < br>
if that matters. The a's printed are just test data.
On debugging the TextView, it appears the data is there (in the mText variable), but it just doesn't display.
Dialog xml sheet:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true" >
<TextView android:id="@+id/status_olcr_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
</ScrollView>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?android:attr/buttonBarStyle" >
<Button
android:id="@+id/status_olcr_ok"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/ok"
style="?android:attr/buttonBarButtonStyle"
android:clickable="false" />
</LinearLayout>
On screen display of what is happening (but shouldn't):
And this is what should be happening (when there is no layout_gravity attribute):
Any idea of whats happening?
Update: I have turned on 'Show layout margins' and the TextView is rendered above the ScrollView bounds (or other way around).. See below images:
Ended up going with this solution, although I still don't understand what was going on in the first place...
Within the relevant DialogFragment:
scroll = (ScrollView)getView().findViewById(R.id.scroll);
scroll.post(new Runnable() {
@Override
public void run() {
scroll.fullScroll(View.FOCUS_DOWN);
}
});