布局搞砸了更大的上屏幕尺寸,不采取额外的空间的优势在哪里? [英] Layout screwed up on bigger screen sizes, not taking advantage of the extra space?
问题描述
几乎与我的应用程序完成,我打了一个巨大的错误。正如标题所说,我刚才测试了一个Galaxy Nexus的我的应用程序。一个更大的屏幕比我一直在测试迄今我的应用程序。一个Desire HD的。该应用程序看起来很好的DesireHD和非常糟糕的GNexus。
Nearly finished with my app and I hit a huge bug. As the title says; I have just tested my app on a Galaxy Nexus. A bigger screen than what I've been testing my app on so far. A Desire HD. The app looks fine on the DesireHD and really bad on the GNexus.
下面是我的意思: Desire HD的屏幕截图和的 GNexus截图
Here is what I mean: Desire HD screenshot and the GNexus screenshot
我创建图像的每个文件夹-hdpi -xhdpi等我跟着3:4:6:从开发者指南8比正确地创建他们。这肯定从xhdpi拍摄的图像,因为它应该。我可以说,是因为公司简介和反馈ImageViews改变设计。
I've created images for each folder -hdpi -xhdpi etc. I followed the 3:4:6:8 ratio from the dev guide to create them correctly. It's definitely taking the images from xhdpi as it should. I can tell this because the aboutus and feedback ImageViews change design.
一切有一个ImageView的,我要指出。我不知道他们为什么显示不正确。我试图创造布局XLARGE在布局sw360dp一个main.xml中,事后但既不固定的问题。事情看起来真的格格不入。考虑到它拿起xhdpi图像,我不知道为什么他们不会正确缩放。如果需要的话,我将发布我的XML。我已经回因为它似乎没有什么区别只是有一个水库布局文件夹中。
Everything there is an ImageView, I should mention that. I don't know why they are not showing up correctly. I tried creating a main.xml in layout-xlarge and afterwards in layout-sw360dp but neither fixed the issue. Things look really out of place. Considering it's picking up the xhdpi images I don't know why they won't scale correctly. I will post my XML if need be. I've gone back to only having a res-layout folder since it seems to make no difference.
还不如只需添加我的XML现在:在这里,我们走了, http://pastebin.com/PkzSDxxw - 我的色彩$ C $光盘,它上面的截图
Might as well just add my XML now: Here we go, http://pastebin.com/PkzSDxxw - I've colour coded it with the screenshots above.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:background="@color/mainback">
<!-- Title contains application info and content starts immediately below. -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- red -->
<ImageView
android:id="@+id/ColourTitle"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:src="@drawable/main_colourtitle"
android:contentDescription="@string/ContentDescColourTitle"/>
<!-- blue -->
<ImageView
android:id="@+id/PastSeason"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_below="@id/ColourTitle"
android:contentDescription="@string/ContentDescHistory"
android:layout_marginBottom="12dp"
android:layout_marginTop="12dp"
android:onClick="PastSeason"
android:src="@drawable/main_history"/>
<!-- green first row -->
<LinearLayout
android:id="@+id/DriveCurrent"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_below="@id/PastSeason"
android:gravity="center"
android:layout_marginTop="7dp">
<ImageView
android:id="@+id/Drivers"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:onClick="F1Drivers"
android:src="@drawable/main_driver"
android:contentDescription="@string/ContentDescDriver"
android:layout_marginRight="30dp"/>
<ImageView
android:id="@+id/CurrentF1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:onClick="CurrentSeason"
android:src="@drawable/main_currentseason"
android:contentDescription="@string/ContentDescCurrentF1"
android:layout_marginLeft="15dp"/>
</LinearLayout>
<!-- green 2nd line -->
<LinearLayout
android:layout_below="@id/DriveCurrent"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center"
android:layout_marginTop="10dp"
android:id="@+id/TeamDriverRecord">
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/main_driver_record"
android:contentDescription="@string/ContentDescDriverRecord"
android:layout_marginRight="30dp"
android:onClick="DriverRecord"/>
<ImageView
android:id="@+id/teamrecord"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/main_team_record"
android:contentDescription="@string/ContentDescTeamRecord"
android:layout_marginLeft="15dp"
android:onClick="TeamRecord"/>
</LinearLayout>
<!-- faq aboutus feedback -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@id/TeamDriverRecord">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/main_faq"
android:contentDescription="@string/ContentDescFAQ"
android:onClick="FAQPage">
</ImageView>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/main_feedback"
android:contentDescription="@string/ContentDescFeedback"
android:onClick="FeedbackPage">
</ImageView>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/ContentDescAboutUs"
android:src="@drawable/main_aboutus"
android:onClick="AboutUs">
</ImageView>
</LinearLayout>
</RelativeLayout>
</ScrollView>
我真的可以做一些帮助,这是推动我坚果,我原本以为它全部覆盖。 :(谢谢。
I could really do with some help, this is driving me nuts, I thought I had it all covered. :( Thanks.
编辑:在Eclipse中选择在图形布局选项卡不同的屏幕尺寸,当XML旁边的编码不正确地缩放图像,比4英寸更大的任何屏幕。如果我选择的Nexus S是显示其扩展的罚款。在接下来是GNexus,及以后你会得到同样的问题。该ImageViews不扩展以满足更大的屏幕尺寸。
推荐答案
RelativeLayouts可能会非常棘手与时间,有时它可以作为扭转操作(例如微妙的工作,上述A B不是总是一样的下文B A)。我想提出以下建议:
RelativeLayouts can be tricky to work with at times, sometimes it can be as subtle as reversing the operations (for example, A above B is not always the same as B below A). I'd recommend the following:
在每个子设置以下属性(红,蓝,和三个LinearLayouts)
Set the following properties on each child (red, blue, and the three LinearLayouts)
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
为了让他们扩展到充满整个屏幕。
in order to get them to scale up to fill the screen.
有关各绿色ImageViews,放安卓重力=中心
为了得到每绿地广场是在它的中间是可用的空间 - 这应该为确保一致的间距尽可能。
For each of the green ImageViews, put android:gravity="center"
in order to get each green square to be in the middle of it's available space - this should ensure as consistent a spacing as possible.
在绿色2号线的LinearLayout,把
In green 2nd line LinearLayout, put
android:layout_above="@+id/TeamDriverRecord"
和从FAQ删除以下/关于我们/反馈线
and remove the following from the FAQ/about us/feedback lines
android:layout_below="@id/TeamDriverRecord"
这样做的原因是,它的第一个铺设了绿色的2号线,然后把常见问题/其他的东西行的所有的下方的空间,重写的过程中高度= WRAP_CONTENT - 这是为什么该行是在更大的屏幕上出现较高的,而不是正确地捕捉到了底部。您也可以解决,通过添加的android:layout_alignParentBottom =真正的
来的FAQ的LinearLayout的每个孩子。
The reason for this is that it's laying out the green 2nd line first, then putting the FAQ/other stuff line in all the space below that, overriding the height=wrap_content in the process - that's why that line is appearing higher on the larger screen instead of properly snapping to the bottom. You could also address that by adding android:layout_alignParentBottom="true"
to each child of the FAQ LinearLayout.
这篇关于布局搞砸了更大的上屏幕尺寸,不采取额外的空间的优势在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!