我有以下布局,我希望使textview出现在视图的中间和中间。我该如何实现这个目标?如何将一个textview居中在一个线性布局中
我试着调整各种重力属性时,在图形视图中查看布局,但似乎没有改变它。我希望在我所完成的中心的textview中,但在视图的一半处。
谢谢马特。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/carefreebgscaledalphajpg" >
<TextView
android:id="@+id/textviewdatefornocallspage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="You have no calls for "
android:textSize="25sp" />
</LinearLayout>
感谢工作得很好,现在 – turtleboy
的RelativeLayout的解决方案工作对我来说,但在TextView中,我必须使用'wrap_content'来兼顾宽度和高度。 –
@Jose_GD:在这两种情况下,它都适用于你:)。在使用width属性'match_parent'的情况下,只需添加'layout_gravity =“center”'。就这样 ;) – Houcine