android - 另一个 Android UI 问题
我有一个滚动视图(主要用于横向目的,因为我没有不同的 xml 文件,我正在使用 android:configChanges="orientation") 其中包含一个RelativeLayout,其中有一个LinearLayout。
代码如下所示:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:background="@color/background"
android:padding="10dip" android:layout_width="fill_parent"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout android:layout_height="fill_parent"
android:layout_width="fill_parent">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_gravity="center"
android:orientation="vertical">
<TextView android:textSize="24.5sp" android:textStyle="bold"
android:layout_height="wrap_content" android:layout_gravity="center"
android:text="@string/main_title" android:layout_width="wrap_content">
</TextView>
<ImageView android:src="@drawable/icon"
android:layout_marginTop="20px" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="center" />
<TextView android:textSize="15sp" android:layout_marginTop="20px"
android:layout_height="wrap_content" android:text="@string/time_window_please_select_label"
android:layout_width="wrap_content"></TextView>
<Spinner android:layout_height="wrap_content" android:id="@+id/spinner"
android:prompt="@string/time_window_prompt" android:layout_width="fill_parent"></Spinner>
<Button android:layout_height="wrap_content"
android:layout_marginTop="20px" android:id="@+id/start_button"
android:text="@string/start_label" android:layout_width="fill_parent"></Button>
<TextView android:layout_height="wrap_content"
android:layout_marginTop="20px" android:id="@+id/status_label"
android:layout_width="wrap_content"></TextView>
<TextView android:layout_height="wrap_content"
android:layout_marginTop="20px" android:id="@+id/status_time_label"
android:layout_width="wrap_content">
</TextView>
</LinearLayout>
<ImageView android:id="@+id/info_button" android:src="@drawable/info"
android:layout_alignParentBottom="true" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="bottom|right" />
</RelativeLayout>
</ScrollView>
除了最后的 ImgView (info_button) 之外,在纵向和横向模式下,一切都工作正常。 我使用了相对布局,因为我认为我能够将其放置在屏幕的右下角(底部和右侧有一点边距是理想的)...
这就是我得到的...
http://www.doc.ic.ac.uk/~am907/wrong.png任何
帮助表示赞赏!
编辑:完整 XML 文件的链接 http://pastebin.com/Cce4AC4v (出于某种原因我不能'在预览模式下看不到全部内容,但当我尝试以文本形式重新复制时它就在那里)
谢谢 安德烈亚斯
I have a scrollview ( mainly for landscape purposes, as I don't have a different xml file, I'm using android:configChanges="orientation")
which contains a RelativeLayout and within it there's a Linear Layout.
The code looks like this:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:background="@color/background"
android:padding="10dip" android:layout_width="fill_parent"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout android:layout_height="fill_parent"
android:layout_width="fill_parent">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_gravity="center"
android:orientation="vertical">
<TextView android:textSize="24.5sp" android:textStyle="bold"
android:layout_height="wrap_content" android:layout_gravity="center"
android:text="@string/main_title" android:layout_width="wrap_content">
</TextView>
<ImageView android:src="@drawable/icon"
android:layout_marginTop="20px" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="center" />
<TextView android:textSize="15sp" android:layout_marginTop="20px"
android:layout_height="wrap_content" android:text="@string/time_window_please_select_label"
android:layout_width="wrap_content"></TextView>
<Spinner android:layout_height="wrap_content" android:id="@+id/spinner"
android:prompt="@string/time_window_prompt" android:layout_width="fill_parent"></Spinner>
<Button android:layout_height="wrap_content"
android:layout_marginTop="20px" android:id="@+id/start_button"
android:text="@string/start_label" android:layout_width="fill_parent"></Button>
<TextView android:layout_height="wrap_content"
android:layout_marginTop="20px" android:id="@+id/status_label"
android:layout_width="wrap_content"></TextView>
<TextView android:layout_height="wrap_content"
android:layout_marginTop="20px" android:id="@+id/status_time_label"
android:layout_width="wrap_content">
</TextView>
</LinearLayout>
<ImageView android:id="@+id/info_button" android:src="@drawable/info"
android:layout_alignParentBottom="true" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="bottom|right" />
</RelativeLayout>
</ScrollView>
Everything works fine, both in portrait and loandscape mode except for the ImgView (info_button) at the very end.
I used a Relative Layout because I thought I'd be able to position it on bottom right hand corner (a bit of margin would be desirable bottom and right) of the screen...
This is what I get instead...
http://www.doc.ic.ac.uk/~am907/wrong.png
any help appreciated!
EDIT: The link to the full XML file http://pastebin.com/Cce4AC4v (for some reason I can't see it all in preview mode but it's there when I try to re-copy in the text form)
Thanks
andreas
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
而不是:
尝试:
编辑:再次阅读您的问题,我相信问题出在
ScrollView
上。我不确定你为什么使用这种类型的布局。您可以摆脱它以支持相对布局,这应该可以解决您的问题。我不知道为什么你觉得这项活动需要支持景观。如果是这样,我会将 ScrollView 分解为单个视图对象并尝试解决该问题。Instead of:
Try:
Edit: Reading your question again, I believe the problem is the
ScrollView
. I'm not sure why you are using this type of layout. You could get rid of it in favor of the relative layout and that should solve your problem. I'm not sure why you feel this activity needs to support landscape. If so, I would boil theScrollView
down to a single view object and try to troubleshoot that.我知道你想将该图像放置在右下角的位置。如果是这样,则给出:
如果这不是解决方案,您能否放置您想要的屏幕以准备好,以便我们可以交叉检查您的布局。
I have understood that u want to place that image at bottom - right location. If so, then give:
If this is not the solution, could you place ur desired screen to be prepared, so that we can cross check ur layout.