I am working with a layout that contains a LinerLayout
and a TextView
.
When I set the gravity
attribute to the TextView
it stops showing on the device, yet shows up on the android layout preview.
Here is the xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/txtProductName"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="0.1"
android:background="@android:color/black"
android:ellipsize="start"
android:gravity="center"
android:text="TextView"
android:textColor="@android:color/white"
android:textSize="20sp" />
<LinearLayout
android:id="@+id/grapher"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.9"
android:background="#000000"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
Here is how it looks on the preview screen
Yet on the device it stops showing
But when I remove the gravity
attribute it shows up on the device. Why is this happening? How should I fix this?