Hi,
I'm having issues with TextViews and centering the text within the text region. Specifically, I have a TextView, but when I have text inside that contains letters that straddle down the bottom margin (i.e. p, g, q, y, etc), those letters are getting cut-off. I'm trying to center the text within the region but haven't had much luck.
[Updated] I now resolved the letters getting cut-off at the bottom using wrap_content as my height, but found another problem. It now appears that the text is positioned low in the region, leaving this gap at the top. I modified my layout to reflect the latest (see below). Basically, those characters that were getting cutoff before (g, y, j, etc) are touching the region right below which is fine, but it appears to leave a padding at the top. I tried to change the gravity to center_vertical or center, but don't have much luck:
Note, I have to work with the specs given the textSizes (i.e. I can't change the values for these)
<LinearLayout
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="43.3dip"
android:background="@drawable/custom_bg"
android:orientation="horizontal">
<ImageButton
android:id="@+id/headshot"
android:layout_width="43.3dip"
android:layout_height="43.3dip"
android:src="@drawable/sample"
android:background="@drawable/head_btn"
android:layout_gravity="center" />
<RelativeLayout
android:id="@+id/name_and_email"
android:layout_width="230.7dip"
android:layout_height="43.3dip"
android:orientation="vertical">
<TextView
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/custom_color"
android:textSize="18.6sp"
android:singleLine="true"
android:ellipsize="end"
android:layout_alignParentTop="true"
android:gravity="center_vertical"
android:background="#c5ff15"
android:lineSpacingExtra="0sp"
android:text="AaBbCcDdGgJjTtYy" />
<TextView
android:id="@+id/email"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/custom_color"
android:textSize="13.3sp"
android:singleLine="true"
android:ellipsize="end"
android:layout_centerInParent="true"
android:layout_below="@id/name"
android:gravity="center_vertical"
android:visibility="gone"
android:text="[email protected]" />
</RelativeLayout>
<ImageButton
android:id="@+id/headshot2"
android:layout_width="43.3dip"
android:layout_height="43.3dip"
android:src="@drawable/sample"
android:background="@drawable/head_btn2"
android:layout_gravity="center" />
</LinearLayout>
Can anyone help?
MB