我的项目不支持多设备屏幕视图

2024-01-26

我有一个菜单屏幕 XML。当我打开项目宽屏幕时,它不适应所有屏幕尺寸。我怎样才能克服这个问题。

当我想添加有关此问题的图片时,我认为我需要 10 次代表。观点 :)

有人可以帮助我吗?

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/samsun"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:text="@string/samsun"
            android:textColor="#FFFF" />

        <Button
            android:id="@+id/trabzon"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:text="@string/trabzon"
            android:textColor="#FFFF" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/adana"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:text="@string/adana"
            android:textColor="#FFFF" />

        <Button
            android:id="@+id/antalya"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:text="@string/antalya"
            android:textColor="#FFFF" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/izmir"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:padding="10dp"
            android:text="@string/izmir"
            android:textColor="#FFFF" />

        <Button
            android:id="@+id/bursa"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:padding="10dp"
            android:text="@string/bursa"
            android:textColor="#FFFF" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/istanbul1"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:padding="10dp"
            android:text="@string/gayrettepe"
            android:textColor="#FFFF" />

        <Button
            android:id="@+id/istanbul2"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:padding="10dp"
            android:text="@string/acibadem"
            android:textColor="#FFFF" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/erzurum"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:padding="10dp"
            android:text="@string/erzurum"
            android:textColor="#FFFF" />

        <Button
            android:id="@+id/diyarbakir"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:padding="10dp"
            android:text="@string/diyarbakir"
            android:textColor="#FFFF" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/ankara"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:padding="10dp"
            android:text="@string/ankara"
            android:textColor="#FFFF" />

        <Button
            android:id="@+id/kayseri"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:padding="10dp"
            android:text="@string/kayseri"
            android:textColor="#FFFF" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/alcatel"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:padding="10dp"
            android:text="@string/alcatel"
            android:textColor="#FFFF" />

        <Button
            android:id="@+id/huawei"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:padding="10dp"
            android:text="@string/huawei"
            android:textColor="#FFFF" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/backbone"
            android:layout_width="fill_parent"
            android:layout_height="150dp"
            android:background="@drawable/selector"
            android:padding="10dp"
            android:text="@string/backbone"
            android:textColor="#FFFF" />



    </LinearLayout>
</LinearLayout>

在 android 中,为了支持尽可能多的设备,您可以为一种布局提供多个定义。首先,您需要将这些文件夹添加到您的资源中,并且对于每个文件夹,您可以指定相同布局的不同 xml 文件,以满足您希望使用应用程序的设备屏幕。

以下是文件夹结构的示例:

res/layout/my_layout.xml             // layout for normal screen size ("default")
res/layout-small/my_layout.xml       // layout for small screen size
res/layout-large/my_layout.xml       // layout for large screen size
res/layout-xlarge/my_layout.xml      // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation

res/layout/main_activity.xml           // For handsets (smaller than 600dp available width)
res/layout-sw600dp/main_activity.xml   // For 7” tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml   // For 10” tablets (720dp wide and bigger)

(在应用程序清单中)

<supports-screens 
        android:smallScreens="true" 
        android:normalScreens="true" 
        android:largeScreens="true"
        android:xlargeScreens="true"  
        android:anyDensity="true"/>

有关支持多个屏幕的更多信息,我强烈建议阅读有关它的谷歌文档。Here http://developer.android.com/guide/practices/screens_support.html是文档的链接。http://developer.android.com/guide/practices/screens_support.html http://developer.android.com/guide/practices/screens_support.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

我的项目不支持多设备屏幕视图 的相关文章

随机推荐

  • setState/在外部函数react中使用State

    考虑这个伪代码 component js import someFunc from common functions js export default class MyComp extends Component constructor
  • 需要用户凭据才能获取访问令牌。请调用非静默的 acquireTokenWithResource 方法

    我正在我的应用程序中使用 ADALiOS 进行身份验证 当用户登录应用程序时 我收到以下错误 参数 cacheItem scopes 无效 值 null 和 需要用户凭据来获取访问令牌 请调用非静默 acquireTokenWithReso
  • Android WebView:网址加载后崩溃

    当使用我的 webView 加载 url 时 应用程序在几秒钟后崩溃 没有错误日志 我的代码 wv new WebView this wv clearCache true wv clearHistory wv getSettings set
  • 创建字符数组以避免缩小

    我正在编写一个单元测试 根据预期数组检查一些二进制数据 有问题的预期数组只是一些字节序列 具体并不重要 char expected 0x42 0xde 0xad 0xbe 0xef 这在 C 中编译得很好 但在 C 11 中 这会发出有关缩
  • 为什么类型化可选参数不能有默认值 Null?

    在 ActionScript 3 中 当您通过给定默认值来声明可选参数时 该值null不能用于类型参数 function Action Param int null 1184 Incompatible default value of ty
  • 主类中的 Spring-Boot @Autowired 变为 null

    我想连接到 Sonic Broker 主题并侦听任何传入的 XML 消息 我做了如下的事情 应用程序 java SpringBootApplication ComponentScan com mainpack com msgpack jms
  • 如何避免数组超出范围

    有人知道如何避免错误array out of range当尝试在指标缓冲区中显示大量柱 比方说 7000 时 我有一个类似的问题 我总是遇到 Array out of range 我的一个缓冲区出现错误 我检查过ArraySize 返回了0
  • 如何在 Eclipse 上设置 PHP 分析?

    我已经在 Galileo 上设置了 Eclipse PDT 我能够运行和调试在 XAMPP 上设置的 PHP 站点 问题是 我想分析其中一个网站 但我无法弄清楚如何设置它 当我右键单击 PHP 项目时 会出现一个分析菜单 但没有指示如何从那
  • 在 postgreSQL 中创建表

    我不明白这个查询有什么问题 查询工具不想在 PostgreSQL 中创建表 CREATE TABLE article article id bigint 20 NOT NULL auto increment article name var
  • 通过chart.js中图例的一键事件隐藏或显示两个数据集

    我想展示 30 天的 2 个班次的机器停机时间的可视化 白天 12 小时 和夜间 12 小时 因此 我将堆叠条形图与组一起使用 并且看起来不错 接受我不想让图例显示两个班次 白天和晚上 带组的堆积条形图 https i stack imgu
  • struts2 修剪从表单获得的所有字符串

    我使用struts2开发Web应用程序 我想改进从表单中获取字符串的方法 为此 需要修剪所有字符串 如果获得的字符串为空 则设置null到字段 为此 我创建了字符串转换器 public class StringConverter exten
  • 是否可以从 http 标头中找到文件名

    通常在下载文件时 假设使用QNetworkAccessManager 文件名不存在于链接末尾 在这种情况下如何获得正确的文件名 即使链接不包含名称提示 Firefox 也始终会下载具有正确名称和扩展名的文件 我们可以使用 mime 类型获得
  • Log4j2 Syslog Appender(TCP 协议)在多行中发送异常堆栈跟踪并显示错误的日志级别

    我正在使用 log4j2 和 syslog 附加程序 我使用 TCP 作为协议和 Kiwi 系统日志服务器 发送错误消息时 异常堆栈跟踪通过 TCP 分多行发送 每一行位于一个数据包中 堆栈跟踪的第一行显示 Kiwi syslog 服务器中
  • 如何从 C# 显示“显示设置”窗口

    如何从 C 显示 Windows 显示设置 分辨率设置 窗口 可以调整屏幕分辨率的那个 我找到了一种方法通过 p invoke 更改显示设置 http pinvoke net default aspx user32 ChangeDispla
  • DocuSign API:在同一信封中发送多个文档的签名问题

    使用 C DocuSign API SDK 4 5 2 我将在同一个信封中寄出 3 份文件以供签名 每个文档将使用相同的服务器模板 它只是使用锚标记将签名元素放置在文档上 我可以寄出信封 然后从 DocuSign 收到电子邮件以查看 签署文
  • 仅返回具有最近 TIME 值的记录?

    我有一个表需要进行一些数据转换 这是一个简单的跟踪表 如下所示 SSN9 0 KEY 例如 123456789 非空 DATE8 0 KEY 例如 20131202 非空 TIME6 0 KEY 例如 133000 非空 打印 新Z 例如2
  • 使用 Namecheap DNS 的 Amazon S3 静态托管 - 如何正确路由非 www 前缀 URL

    我一直在阅读其他帖子 试图深入了解这个问题 但我需要一些澄清 当我进入时 我能够让所有域请求完美地到达我的 Amazon S3 存储桶www example com MyDirectory 如果我输入example com MyDirect
  • 使用 Glide 加载到 Imageview 但延迟

    我使用 Glide 从 Firebase 加载 ImageView 当我运行我的应用程序时 我的 ImageView 会延迟 就像我视频中的牙齿一样 https www youtube com watch v 6Mj0Xq3M8n0 htt
  • DB Design允许用户定义产品、产品规格并让自己插入订单

    我正在设计一个数据库 因为我需要开发这样一个 CRM 用户可以在其中指定新产品 产品规格和定价 然后让自己为上一步中指定的产品插入订单 当然 插入的数据需要根据它们在数据库中指定的内容进行评估 我举个例子可能会更清楚 user1 创建一个产
  • 我的项目不支持多设备屏幕视图

    我有一个菜单屏幕 XML 当我打开项目宽屏幕时 它不适应所有屏幕尺寸 我怎样才能克服这个问题 当我想添加有关此问题的图片时 我认为我需要 10 次代表 观点 有人可以帮助我吗