【发布时间】:2013-11-12 04:08:09
【问题描述】:
我尝试了一堆不同的排列设置填充、高度等以及不同的布局属性,但仍然无法弄清楚为什么 Android 标题栏会覆盖第一个视图项 (EditText)。
布局 xml 如下所示:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0099cc"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".Blotter" >
<EditText
android:id="@+id/order_entry"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/dummy_order"
android:keepScreenOn="true"
android:singleLine="true"
android:textAlignment="center"
android:textColor="#33b5e5"
android:textSize="26sp"
android:textStyle="bold" />
<TextView
android:id="@+id/status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:keepScreenOn="true"
android:text="@string/dummy_content"
android:textAlignment="center"
android:textColor="#33b5e5"
android:textSize="24sp"
android:textStyle="bold" />
<GridView
android:id="@+id/orders"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/status"
android:layout_alignParentLeft="true"
android:layout_below="@id/order_entry" />
</RelativeLayout>
模拟器中的结果是这样的:
有点难看,但我圈出了标题重叠的EditText视图。不过,Eclipse ADT 图形布局视图中的渲染看起来不错。
【问题讨论】:
-
您在使用 ActionBarSherlock 之类的操作栏库吗?你在使用碎片吗?或使用developer.android.com/reference/android/view/… ?发布有关如何使用该布局的代码。同时,还有一个可能与您的问题有关的问题:stackoverflow.com/questions/19635440/…
-
@frozenkoi:这只是一个基本的入门项目。无ActionBar,一般在创建Eclipse Android 项目时采用默认设置。我很快就会发布代码(但几乎没有什么可看的)。不知何故,只是默认的 Xml 设置并不能阻止标题与第一个视图项重叠。