我有一个问题,似乎相当琐碎,但我迄今为止还没有能够解决它。
我有一个全屏的横屏活动,在其中我有一个包含两个 TextView 的 LinearLayout,每个 TextView 占据屏幕的一半。其中一个 TextView 必须具有居中的字符,无论字体大小如何。
问题是,当我增加这个字符的字体大小时,它不会居中,而是其中心线位于屏幕中心线以下。
这是一个在 800*480 屏幕上使用 200sp 字符大小的活动,看起来很好 - 字符被居中:
http://i122.photobucket.com/albums/o251/px_seven/char_200_sp.jpg
这是一个在 800*480 屏幕上使用 300sp 字符大小的活动,现在字符已经向下移动:
http://i122.photobucket.com/albums/o251/px_seven/char_300_sp.jpg
这是布局(我在代码中从默认的字体大小 250sp 进行了更改):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true">
<TextView
android:id="@+id/tv1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_gravity="center"
android:gravity="center_horizontal"
android:background="#000000" />
<TextView
android:id="@+id/tv2"
android:lines="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_gravity="center"
android:gravity="center"
android:background="#000000"
android:text="N"
android:textSize="250sp" />
</LinearLayout>
有人看到问题在哪里了吗?
谢谢, Fredric