【发布时间】:2011-03-31 17:12:56
【问题描述】:
我的项目工作正常,突然我的按钮上的文本被垂直显示。我的意思是不是显示 map_infobutton
Info
它正在显示
I
n
f 和 o 超出了按钮的范围,即使我在包含按钮的 TableLayout 中指定了 height=wrap_content。
在 Eclipse 的“布局”选项卡中显示正常,仅在模拟器中垂直显示(未在目标硬件上尝试)
其中一个按钮的getPaddingLeft 在代码中的不同点返回11。不知道它是从哪里得到的,但无论如何间距看起来都比那个大。我确实有三个按钮并拿走了一个,但是两个和三个按钮都存在问题。
我的布局是:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/map_header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:paddingTop="8px"
android:paddingBottom="8px"
android:gravity="center"
android:textColor="@color/header_foreground"
android:background="@color/header_background"
android:text="@string/map_header"/>
<TableLayout
android:id="@+id/map_footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:paddingTop="4px"
android:paddingLeft="2px"
android:paddingRight="2px"
android:stretchColumns="*"
android:textColor="@color/footer_foreground"
android:background="@color/footer_background">
<TableRow>
<Button
android:id="@+id/map_infobutton"
android:layout_width="0px"
android:layout_weight="1"
android:text="@string/map_infobutton" />
<Button
android:id="@+id/map_selectbutton"
android:layout_width="0px"
android:layout_weight="1"
android:text="@string/map_selectbutton" />
</TableRow>
</TableLayout>
<LinearLayout
android:id="@+id/map_selectiondetails"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/map_footer"
android:orientation="horizontal"
android:gravity="center"
android:textColor="@color/main_foreground"
android:background="@color/main_background" >
<TextView
android:id="@+id/map_selectionname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="4px"
android:textColor="@color/main_foreground"
android:background="@color/main_background"/>
<TextView
android:id="@+id/map_selectiondistance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="4px"
android:paddingRight="4px"
android:textColor="@color/main_foreground"
android:background="@color/main_background"/>
<TextView
android:id="@+id/map_selectionvar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="4px"
android:paddingRight="4px"
android:textColor="@color/main_foreground"
android:background="@color/main_background"/>
<TextView
android:id="@+id/map_selectionvar2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="4px"
android:paddingRight="4px"
android:textColor="@color/main_foreground"
android:background="@color/main_background"/>
<TextView
android:id="@+id/map_selectionvar3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="4px"
android:textColor="@color/main_foreground"
android:background="@color/main_background"/>
</LinearLayout>
<SurfaceView
android:id="@+id/map_map"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_above="@id/map_selectiondetails"
android:layout_below="@id/map_header"
android:clickable="true"/>
</RelativeLayout>
有什么想法吗?另外,如果您对我如何创建布局有任何意见,因为我是新手,而且似乎有很多可用选项,但我正在努力使其尽可能简单。
【问题讨论】:
-
您的布局与您在运行 2.2 的摩托罗拉机器人和运行 2.1 的 emu 上描述的不符。 emu 上可能没有正确安装新版本。尝试清理并重新部署一个项目,如果这不起作用,则重新创建 emu 映像。
标签: android