我有如下的布局Android的文字位置
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@color/all_white"
android:gravity="center">
<Button android:id="@+id/mq_categories" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_margin="5dp"
android:text="Browse Quiz Categories" android:textColor="#EDFF99"
android:background="@drawable/custom_button" />
<Button android:id="@+id/mq_random" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_margin="5dp"
android:text="Enter Random Quiz" android:textColor="#EDFF99"
android:background="@drawable/custom_button" />
<Button android:id="@+id/mq_profile" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_margin="5dp"
android:text="My Profile" android:textColor="#EDFF99"
android:background="@drawable/custom_button" />
</LinearLayout>
这给输出
现在我需要在添加一个欢迎文本屏幕的顶部部分
当我像这样添加文本视图时,只显示欢迎文本并没有任何按键和没有滚动
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@color/all_white"
android:gravity="center">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mg_userinfo" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:text="Welcome"
android:gravity="center" />
<Button android:id="@+id/mq_categories" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_margin="5dp"
android:text="Browse Quiz Categories" android:textColor="#EDFF99"
android:background="@drawable/custom_button" />
<Button android:id="@+id/mq_random" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_margin="5dp"
android:text="Enter Random Quiz" android:textColor="#EDFF99"
android:background="@drawable/custom_button" />
<Button android:id="@+id/mq_profile" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_margin="5dp"
android:text="My Profile" android:textColor="#EDFF99"
android:background="@drawable/custom_button" />
</LinearLayout>
在下面试图铺陈欢迎文本在按钮的下方显示,但按键得到了转移到了屏幕的顶部
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@color/all_white"
android:gravity="center">
<Button android:id="@+id/mq_categories" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_margin="5dp"
android:text="Browse Quiz Categories" android:textColor="#EDFF99"
android:background="@drawable/custom_button" />
<Button android:id="@+id/mq_random" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_margin="5dp"
android:text="Enter Random Quiz" android:textColor="#EDFF99"
android:background="@drawable/custom_button" />
<Button android:id="@+id/mq_profile" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_margin="5dp"
android:text="My Profile" android:textColor="#EDFF99"
android:background="@drawable/custom_button" />
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mg_userinfo" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:text="Welcome"
android:gravity="center" />
</LinearLayout>
我该如何在顶部添加欢迎文字?屏幕上的中心按钮?
不鼓励使用px。它不能在不同屏幕密度的设备上正确缩放。始终使用dip或dp(两者都相同)。 – Mudassir 2010-12-03 05:04:50