【发布时间】:2011-10-24 17:42:17
【问题描述】:
我正在开发一个 Android 应用(见屏幕截图)。
我的布局在图形编辑器中看起来不错。但是,当应用程序在模拟器和安卓手机上运行时,屏幕底部的 1/4 会从视图中被剪掉。该应用程序有几个活动,而且问题似乎对所有人都很普遍。
这是我正在使用的布局。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_width="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android" android:clipChildren="false" android:clipToPadding="false" android:layout_height="fill_parent">
<ImageView android:layout_height="wrap_content" android:src="@drawable/simpsonstextblack" android:layout_width="fill_parent" android:id="@+id/TitleImage" android:paddingBottom="25dp"></ImageView>
<RelativeLayout android:layout_below="@+id/TitleImage" android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/RelativeLayout1" android:padding="5dp">
<Button android:text="Take the Simpsons Challenge" android:gravity="center" android:clickable="true" android:id="@+id/ChallengeButton" android:layout_width="fill_parent" android:textSize="20dp" android:background="@drawable/buttonbackgroundblue" android:layout_height="50dp"></Button>
<TextView android:layout_width="fill_parent" android:layout_below="@+id/ChallengeButton" android:layout_alignLeft="@+id/ChallengeButton" android:id="@+id/spacer1" android:layout_height="6dp"></TextView>
<Button android:layout_width="fill_parent" android:text="Free Play" android:clickable="true" android:id="@+id/FreePlayButton" android:layout_height="50dp" android:textSize="20dp" android:background="@drawable/buttonbackgroundblue" android:layout_below="@+id/spacer1"></Button>
<TextView android:layout_width="fill_parent" android:id="@+id/spacer2" android:layout_below="@+id/FreePlayButton" android:layout_alignLeft="@+id/FreePlayButton" android:layout_height="6dp"></TextView>
<Button android:layout_height="50dp" android:textSize="20dp" android:id="@+id/HighScoreButton" android:background="@drawable/buttonbackgroundblue" android:layout_width="fill_parent" android:text="High Scores" android:layout_below="@+id/spacer2"></Button>
<TextView android:layout_width="fill_parent" android:id="@+id/spacer3" android:layout_below="@+id/HighScoreButton" android:layout_alignLeft="@+id/HighScoreButton" android:layout_height="6dp"></TextView>
<Button android:layout_height="50dp" android:textSize="20dp" android:id="@+id/HelpButton" android:background="@drawable/buttonbackgroundblue" android:layout_width="fill_parent" android:text="Help" android:layout_below="@+id/spacer3"></Button>
</RelativeLayout>
<RelativeLayout android:layout_below="@+id/RelativeLayout1" android:layout_width="fill_parent" android:id="@+id/RelativeLayout2" android:clipChildren="false" android:clipToPadding="false" android:layout_height="fill_parent">
<TextView android:id="@+id/spacer1" android:layout_width="fill_parent" android:layout_height="30dp"></TextView>
<TextView android:layout_below="@+id/spacer1" android:layout_height="wrap_content" android:layout_width="fill_parent" android:textAppearance="?android:attr/textAppearanceMedium" android:id="@+id/QuoteText" android:text='"A woman is a lot like a refrigerator. Six feet tall, 300 pounds…it makes ice. Heres some extra filler text just to demonstrate to you that if you add enough text it will most likely get clipped at some random point in the screen seemingly for no reason."'></TextView>
</RelativeLayout>
</RelativeLayout>
【问题讨论】:
-
我无法在我的设备上重现此问题。当您在设备上运行时,它会显示与模拟器相同的内容吗?
-
是的,截图来自模拟器本身。尝试在底部的文本视图中添加几行文本,看看它们是否被剪辑。
-
我的意思是它可能在物理设备上正常工作而不是在模拟器中,尽管它应该在模拟器中工作。只是想排除这种可能性。我已经添加了足够多的文本行,让它滚动到屏幕底部,但它只会在我的设备上的屏幕边缘剪辑它。
-
有趣。我确实在朋友的手机上尝试了旧版本的布局,并且遇到了与模拟器相同的问题,但也许一些小的修补程序修复了它。我试试看。
-
手机上仍然没有变化。问题似乎是应用程序范围内的,并且显然因手机而异。是否有任何应用程序范围的变量可以控制这一点?我是开发新手,所以我完全有可能犯了一个非常愚蠢的错误。
标签: android layout graphics view clipped