android应用程序不能从7扩展到10
我为我的7英寸平板电脑编写了我的应用程序。它非常适合这个屏幕。 应用程序基于嵌套的LinearLayout。 所有LinearLayout均设置为“带”和“高”,以匹配父项或填充父项。 我没有用dpi固定任何尺寸或高度。 因此,当我在10英寸平板电脑上启动我的应用程序时,我认为它适合新的屏幕。相反,在7英寸平板电脑上运行时,应用程序占用了相同的空间。 我的应用程序只能在7英寸平板电脑或10英寸平板电脑上运行。 为什么我的应用程序不适合新屏幕 现在我读了一篇关于文件夹布局的文章,7英寸平板电脑的大布局,10英寸平板电脑的大布局。 我的所有xml布局都在?布局?文件夹中。 我必须创建这些新文件夹?并将我的xml布局文件复制到这些新文件夹中? 在哪里可以找到有关如何设置应用程序以使其适合7到10英寸的说明? 提前谢谢! 塞尔吉奥 我还使用: 用于填充/边距的DP单位和用于字体和权重的SP单位 捕获: 代码如下:android应用程序不能从7扩展到10,android,android-layout,layout,Android,Android Layout,Layout,我为我的7英寸平板电脑编写了我的应用程序。它非常适合这个屏幕。 应用程序基于嵌套的LinearLayout。 所有LinearLayout均设置为“带”和“高”,以匹配父项或填充父项。 我没有用dpi固定任何尺寸或高度。 因此,当我在10英寸平板电脑上启动我的应用程序时,我认为它适合新的屏幕。相反,在7英寸平板电脑上运行时,应用程序占用了相同的空间。 我的应用程序只能在7英寸平板电脑或10英寸平板电脑上运行。 为什么我的应用程序不适合新屏幕 现在我读了一篇关于文件夹布局的文章,7英寸平板电脑的大
<LinearLayout 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:adjustViewBounds="true"
android:background="@drawable/wood_floor"
android:orientation="vertical"
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=".ScorerActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/custom_txt_opal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="30"
android:orientation="horizontal"
android:gravity="center"
>
<TextView
android:id="@+id/lblAvv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="Punti Avversari" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="40"
android:orientation="horizontal"
android:gravity="center"
>
<TextView
android:id="@+id/lblPuntiPartita"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="Punti Giocatore"
/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="30"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="@+id/lblTotalePuntiPartita"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="Punti Partita" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<View
android:id="@+id/view1"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#000000" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="15"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/btnAzione7"
style="@style/btnStyleOrange"
android:layout_weight="50"
android:onClick="goStartAzione"
android:tag="7"
android:text="7" />
<Button
android:id="@+id/btnAzione1"
style="@style/btnStyleOrange"
android:layout_height="wrap_content"
android:layout_weight="50"
android:onClick="goStartAzione"
android:tag="1"
android:text="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/btnAzione8"
style="@style/btnStyleOrange"
android:layout_weight="50"
android:onClick="goStartAzione"
android:tag="8"
android:text="8" />
<Button
android:id="@+id/btnAzione2"
style="@style/btnStyleOrange"
android:layout_weight="50"
android:onClick="goStartAzione"
android:tag="2"
android:text="2" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/btnAzione9"
style="@style/btnStyleOrange"
android:layout_weight="50"
android:onClick="goStartAzione"
android:tag="9"
android:text="9" />
<Button
android:id="@+id/btnAzione3"
style="@style/btnStyleOrange"
android:layout_weight="50"
android:onClick="goStartAzione"
android:tag="3"
android:text="3" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/btnAzione10"
style="@style/btnStyleOrange"
android:layout_weight="50"
android:onClick="goStartAzione"
android:tag="10"
android:text="10" />
<Button
android:id="@+id/btnAzione4"
style="@style/btnStyleOrange"
android:layout_weight="50"
android:onClick="goStartAzione"
android:tag="4"
android:text="4" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/btnAzione11"
style="@style/btnStyleOrange"
android:layout_weight="50"
android:onClick="goStartAzione"
android:tag="11"
android:text="11" />
<Button
android:id="@+id/btnAzione5"
style="@style/btnStyleOrange"
android:layout_weight="50"
android:onClick="goStartAzione"
android:tag="5"
android:text="5" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/btnAzione12"
style="@style/btnStyleOrange"
android:layout_weight="50"
android:onClick="goStartAzione"
android:tag="12"
android:text="12" />
<Button
android:id="@+id/btnAzione6"
style="@style/btnStyleOrange"
android:layout_weight="50"
android:onClick="goStartAzione"
android:tag="6"
android:text="6" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="45"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/custom_txt_lemon"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="@+id/lblMagliaNumero"
style="@style/BaseTextSize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:text="" />
<TextView
android:id="@+id/lblNomeGiocatore"
style="@style/BaseTextSize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="" />
</LinearLayout>
<ImageView
android:id="@+id/imgHalfCourt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:adjustViewBounds="true"
android:scaleType="matrix"
android:src="@drawable/halfcourt4" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="40"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:gravity="center_vertical|right"
android:orientation="horizontal"
android:paddingBottom="0dp"
android:paddingTop="0dp" >
<Button
android:id="@+id/btnFallo1"
style="@style/txtStyleWhiteShadow"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="20"
android:background="@drawable/custom_btn_opal"
android:gravity="center_vertical|center_horizontal"
android:onClick="setFallo"
android:tag="1"
android:text="1" />
<Button
android:id="@+id/btnFallo2"
style="@style/txtStyleWhiteShadow"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="20"
android:background="@drawable/custom_btn_opal"
android:gravity="center_vertical|center_horizontal"
android:onClick="setFallo"
android:tag="2"
android:text="2" />
<Button
android:id="@+id/btnFallo3"
style="@style/txtStyleWhiteShadow"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="20"
android:background="@drawable/custom_btn_opal"
android:gravity="center_vertical|center_horizontal"
android:onClick="setFallo"
android:tag="3"
android:text="3" />
<Button
android:id="@+id/btnFallo4"
style="@style/txtStyleWhiteShadow"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="20"
android:background="@drawable/custom_btn_opal"
android:gravity="center_vertical|center_horizontal"
android:onClick="setFallo"
android:tag="4"
android:text="4" />
<Button
android:id="@+id/btnFallo5"
style="@style/txtStyleWhiteShadow"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="20"
android:background="@drawable/custom_btn_opal"
android:gravity="center_vertical|center_horizontal"
android:onClick="setFallo"
android:tag="5"
android:text="5" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:gravity="center_vertical|right"
android:orientation="horizontal"
android:paddingBottom="0dp"
android:paddingTop="0dp" >
<Button
android:id="@+id/btnT2Ok"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="28"
android:drawableLeft="@drawable/img_check_48"
android:onClick="mngActionsT2"
android:tag="T2r"
android:text="T2" />
<Button
android:id="@+id/btnT2Ko"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="28"
android:drawableLeft="@drawable/img_delete_48"
android:onClick="mngActionsT2"
android:tag="T2e"
android:text="T2" />
<TextView
android:id="@+id/txtT2rrtt"
style="@style/BaseTextSize"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="25"
android:gravity="center_horizontal"
android:text="00/00" />
<TextView
android:id="@+id/txtT2rrttperc"
style="@style/BaseTextSize"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="19"
android:gravity="center_horizontal"
android:text="0%" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|right" >
<Button
android:id="@+id/btnT3Ok"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="28"
android:drawableLeft="@drawable/img_check_48"
android:onClick="mngActionsT3"
android:tag="T3r"
android:text="T3" />
<Button
android:id="@+id/btnT3Ko"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="28"
android:drawableLeft="@drawable/img_delete_48"
android:onClick="mngActionsT3"
android:tag="T3e"
android:text="T3" />
<TextView
android:id="@+id/txtT3rrtt"
style="@style/BaseTextSize"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="25"
android:gravity="center_horizontal"
android:text="00/00" />
<TextView
android:id="@+id/txtT3rrttperc"
style="@style/BaseTextSize"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="19"
android:gravity="center_horizontal"
android:text="0%" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|right" >
<Button
android:id="@+id/btnTLOk"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="28"
android:drawableLeft="@drawable/img_check_48"
android:onClick="mngActionsTL"
android:tag="TLr"
android:text="TL" />
<Button
android:id="@+id/btnTLKo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="28"
android:drawableLeft="@drawable/img_delete_48"
android:onClick="mngActionsTL"
android:tag="TLe"
android:text="TL" />
<TextView
android:id="@+id/txtTLrrtt"
style="@style/BaseTextSize"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="25"
android:gravity="center_horizontal"
android:text="00/00" />
<TextView
android:id="@+id/txtTLrrttperc"
style="@style/BaseTextSize"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="19"
android:gravity="center_horizontal"
android:text="%" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right" >
<Button
android:id="@+id/txtrimbAttOk"
style="@style/btnStyleSandrift"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="50"
android:onClick="mngActionsRimb"
android:tag="rimbAttAdd"
android:text="+ R. Att." />
<Button
android:id="@+id/txtrimbDifOk"
style="@style/btnStyleSandrift"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="50"
android:onClick="mngActionsRimbDif"
android:tag="rimbDifAdd"
android:text="+ R. Dif." />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right" >
<Button
android:id="@+id/txtPerseOk"
style="@style/btnStyleSandrift"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="50"
android:onClick="mngActionsPallep"
android:tag="pallepAdd"
android:text="+ P. Perse" />
<Button
android:id="@+id/txtRecupeOk"
style="@style/btnStyleSandrift"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="50"
android:onClick="mngActionsPaller"
android:tag="pallerAdd"
android:text="+ P. Rec." />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right" >
<Button
android:id="@+id/btnUndoLastAct"
style="@style/btnStyleSandrift"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="50"
android:onClick="goUndo"
android:text="UNDO ultima azione" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:gravity="center|bottom"
android:orientation="horizontal" >
<TextView
android:id="@+id/lblLastAction"
style="@style/BaseTextSize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ultima azione salvata: " />
<TextView
android:id="@+id/lblLastActionDesc"
style="@style/BaseTextSize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
您必须确保清单文件中支持屏幕中的android:xlargescreenses=“true”
为什么我的应用程序不适合新屏幕
因为您的内容没有填满屏幕。例如,宽度和高度为wrap_content
的按钮,如果内容更大,则会变大,而不是屏幕更大
正如我所建议的,您拒绝发布布局文件。因此,没有人能够为您提供更多具体建议。您可以使用层次结构视图更好地了解布局规则的应用方式,然后您需要决定如何调整这些规则和/或提供更大的内容以便更有效地使用空间
现在我读了一篇关于文件夹布局的帖子,7英寸平板电脑的大布局,10英寸平板电脑的xlarge布局。我所有的xml布局都在?布局?文件夹中
这意味着您将对所有屏幕大小使用相同的布局XML资源。这不一定是个问题
必须创建这些新文件夹吗
如果您想使用,您可以。对于以平板电脑为中心的应用程序,正如您的应用程序一样,您的android:minSdkVersion
应该至少为11,在这种情况下,您可以使用-wNNNdp
资源集,根据当前方向的屏幕宽度设置您想要的分界线
当您在不同时间为同一角色应用不同的资源时,您可以通过这种方式使用多个资源集:不同屏幕大小的不同布局,不同语言的不同字符串翻译,等等
并将我的xml布局文件复制到这些新文件夹中
仅作为起点。如果您正在处理不同的布局资源集,关键是XML布局文件不同。如果您希望始终使用相同的布局文件,则不需要设置不同的目录,也不需要复制文件
您可以将资源集视为有点像CSS媒体查询。在这里,您可以设置在特定条件下应用的CSS规则。对于资源,不同的资源集在目录名上使用后缀来指示在特定情况下应用的“规则”
在哪里可以找到有关如何设置应用程序以使其适合7到10英寸的说明
这方面的内容很多,任何一本严肃的Android书籍都会对其进行广泛的介绍。我发现了为什么我的应用程序不能水平地填满所有空间。 “res”下有一个文件夹“values-sw720dp-land”,其文件dimens.xml包含:
<resources>
<!--
Customize dimensions originally defined in res/values/dimens.xml (such as
screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
-->
<dimen name="activity_horizontal_margin">128dp</dimen>
128dp
我不知道为什么有这么大的水平边距!
现在我必须努力更好地设置我的布局。
谢谢大家的帮助。
塞尔吉奥请发布布局文件。请同时考虑应用程序的屏幕截图来说明您的问题。我必须捕获7和10。我怎样才能添加到这个帖子?抱歉,但我上传图片的信誉不超过10。(您可以将图像上传到Internet上的其他位置,并从您的帖子链接到它们。这是我的:delete android:RequiresMallestWidthDP=“600"谢谢你的建议,但一切都没有改变。@Sergio:这和我预期的差不多。你目前的设计在利用宽度方面做得很好。而且,你的按钮和其他东西在其当前大小上应该是合适的。你可能想改变你的半场规则
ImageView
,这样它就可以增长一点。否则,你要么找些新的东西,或者o加10"平板电脑可以占用空间,或者重新设计布局以更好地利用额外的高度。因为你的问题的答案只是你这边的配置不好,所以我会删除这个问题,因为它对其他任何人都没有帮助。我同意你的看法。但是你真的不认为这个帖子对其他人有用吗?我已经回答了d通过阅读许多其他帖子来回答我的问题,其中许多帖子回答了相同的问题,但总是有些不同。无论如何,多亏了Stack!