不容中心textview's垂直文本 [英] Can´t center textview´s text vertically
问题描述
[解决]我不得不添加的android:fillViewport =真正的
来的滚动型,即固定的文字不是垂直居中的问题
[Solved] I had to add android:fillViewport="true"
to the ScrollView, that fixed the problem with the text not centering vertically.
我知道这已经回答过很多次,但I'm仍然不能垂直居中textview's文本。
I know this has been answered many times before, but I´m still not able to center a textview´s text vertically.
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/relativelayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/icon"
android:layout_width="@dimen/icon_width"
android:layout_height="@dimen/icon_height"
android:src="@drawable/picture" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/icon"
android:gravity="center_vertical"
android:layout_alignBottom="@+id/icon"
android:layout_alignTop="@+id/icon"
android:text="@string/title_text"
android:textSize="@dimen/textsize"
android:textStyle="bold"
android:textColor="@color/color"
android:shadowColor="@color/shadow"
android:shadowRadius="5"/>
</RelativeLayout>
</ScrollView>
通常这应与工作
android:gravity="center_vertical"
,但其对TextView的没有影响...
but it has no effect on the textview...
奇怪的是,我有完全相同的code和汇入作业没有任何问题,在那里工作的第二个应用程序。
Weird thing is that I have a second app with the exact same code and it´s working there without any problems.
/编辑
要澄清我的问题:
这是我现在所拥有的:结果搜索结果
这就是我想要的:结果搜索
To clarify my question:
This is what I have right now:
This is what I want:
推荐答案
本code取代你的TextView,它会正常工作
replace your TextView with this code and it will work fine
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/icon"
android:layout_alignParentTop="true"
android:layout_alignTop="@+id/icon"
android:layout_toRightOf="@+id/icon"
android:shadowColor="@color/shadow"
android:shadowRadius="5"
android:text="@string/title_text"
android:textColor="@color/color"
android:textSize="@dimen/textsize"
android:textStyle="bold" />
这篇关于不容中心textview's垂直文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!