jjzjj

android - 如何为多屏android调整用户界面?

coder 2023-12-28 原文

我有一个 xml 文件如下。

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:background="@drawable/imagesand"
    android:layout_height="match_parent" >
<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    android:orientation="vertical"
    android:paddingLeft="10dp"
    android:paddingRight="10dp" >

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Collaboration Set Up :"
        android:textSize="20dp" />

    <EditText
        android:id="@+id/projectname"
        android:layout_width="match_parent"
        android:layout_height="36dp"
        android:hint="Group Name"
        android:paddingLeft="10dp"
        android:background="@drawable/button"
        android:ems="10" >
    </EditText>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Data To Collect :"
        android:textSize="20dp" />

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

        <CheckBox
            android:id="@+id/fnamechk"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
             android:enabled="false"
            android:textSize="13dp"
            android:text=" First Name" />

        <CheckBox
            android:id="@+id/lnamechk"
             android:textSize="13dp"
            android:layout_width="wrap_content"
            android:checked="true"
             android:enabled="false"
            android:layout_height="wrap_content"
            android:text="Last Name" />

        <CheckBox
            android:id="@+id/personalemailchk"
            android:layout_width="wrap_content"
            android:checked="true"
            android:enabled="false"
            android:layout_height="wrap_content"
            android:text="Personal Email"
            android:textSize="13dp" />

    </LinearLayout>

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

        <CheckBox
            android:id="@+id/workphonechk"
             android:textSize="13dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Work Ph." />

        <CheckBox
            android:id="@+id/companychk"
            android:layout_width="wrap_content"

            android:layout_height="wrap_content"
            android:text="Company"

            android:textSize="13dp" />

        <CheckBox
            android:id="@+id/Workemailchk"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Work Email"
            android:textSize="13dp" />

    </LinearLayout>

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

        <CheckBox
            android:id="@+id/cellchk"
            android:layout_width="wrap_content"
            android:textSize="13dp"
            android:layout_height="wrap_content"
            android:text="MobNo." />

    </LinearLayout>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Data Visible to User:"
        android:textSize="20dp" />

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

        <CheckBox
            android:id="@+id/fname2"
            android:textSize="13dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:enabled="false"
            android:checked="true"
            android:text="First Name" />

        <CheckBox
            android:id="@+id/lname2"
            android:enabled="false"
            android:checked="true"
             android:textSize="13dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Last Name" />

        <CheckBox
            android:id="@+id/personalemail2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:enabled="false"
             android:checked="true"
            android:text="Personal Email"
            android:textSize="13dp" />

    </LinearLayout>

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

        <CheckBox
            android:id="@+id/workphone2"
             android:textSize="13dp"
            android:enabled="false"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Work Ph." />

        <CheckBox
            android:id="@+id/Comoany2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:enabled="false"

            android:text="Company"
            android:textSize="13dp" />

        <CheckBox
            android:id="@+id/workemail2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:enabled="false"
            android:text="Work Email"
            android:textSize="13dp" />

    </LinearLayout>

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

        <CheckBox
            android:id="@+id/cell2"
             android:textSize="13dp"
            android:enabled="false"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Mob.No" />

    </LinearLayout>

    <LinearLayout android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <RadioGroup
        android:id="@+id/radioGroup1"

        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <RadioButton
            android:id="@+id/available"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
         android:textSize="13dp"
            android:text="Available" />

        <RadioButton
            android:id="@+id/none"
            android:textSize="13dp"
            android:layout_gravity="center_horizontal"
            android:layout_width="wrap_content"
                android:layout_marginLeft="50dp"
            android:layout_height="wrap_content"
            android:text="None" />
    </RadioGroup>

    </LinearLayout>
     <LinearLayout android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <RadioGroup
        android:id="@+id/radioGroup2"
        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <RadioButton
            android:id="@+id/Private"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
           android:textSize="13dp"
            android:text="Private" />

        <RadioButton
            android:id="@+id/Public"
              android:layout_marginLeft="65dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
           android:textSize="13dp"
            android:text="Public" />
    </RadioGroup>

    </LinearLayout>

    <Button
        android:id="@+id/generate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:background="@drawable/login"
        android:text="Generate" />

</LinearLayout>
</ScrollView>

当我在较小的设备上打开它时,它看起来像这样。我已经实现了 ScrollView 。

当我在平板电脑中打开时,它看起来像这样。

如您所见,在选项卡中浪费了较大的空间,那么我可以利用可用空间并根据屏幕尺寸使复选框分布在屏幕上吗?

最佳答案

为此您必须使用Configuration Qualifiers,您可以引用以下帖子:

1. Post A 2. Post B

基本上你的元素应该是这样的:

或者,您也可以通过维度来控制布局,例如:

<Button android:width= "@dimen/somewidth"/>

像这样为多个值声明此维度:

关于android - 如何为多屏android调整用户界面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20834995/

有关android - 如何为多屏android调整用户界面?的更多相关文章

  1. ruby - 如何为 emacs 安装 ruby​​-mode - 2

    我刚刚为fedora安装了emacs。我想用emacs编写ruby。为ruby​​提供代码提示、代码完成类型功能所需的工具、扩展是什么? 最佳答案 ruby-mode已经包含在Emacs23之后的版本中。不过,它也可以通过ELPA获得。您可能感兴趣的其他一些事情是集成RVM、feature-mode(Cucumber)、rspec-mode、ruby-electric、inf-ruby、rinari(用于Rails)等。这是我当前用于Ruby开发的Emacs配置:https://github.com/citizen428/emacs

  2. ruby-on-rails - 使用 rails 4 设计而不更新用户 - 2

    我将应用程序升级到Rails4,一切正常。我可以登录并转到我的编辑页面。也更新了观点。使用标准View时,用户会更新。但是当我添加例如字段:name时,它​​不会在表单中更新。使用devise3.1.1和gem'protected_attributes'我需要在设备或数据库上运行某种更新命令吗?我也搜索过这个地方,找到了许多不同的解决方案,但没有一个会更新我的用户字段。我没有添加任何自定义字段。 最佳答案 如果您想允许额外的参数,您可以在ApplicationController中使用beforefilter,因为Rails4将参数

  3. ruby-on-rails - 简单的 Ruby on Rails 问题——如何将评论附加到用户和文章? - 2

    我意识到这可能是一个非常基本的问题,但我现在已经花了几天时间回过头来解决这个问题,但出于某种原因,Google就是没有帮助我。(我认为部分问题在于我是一个初学者,我不知道该问什么......)我也看过O'Reilly的RubyCookbook和RailsAPI,但我仍然停留在这个问题上.我找到了一些关于多态关系的信息,但它似乎不是我需要的(尽管如果我错了请告诉我)。我正在尝试调整MichaelHartl'stutorial创建一个包含用户、文章和评论的博客应用程序(不使用脚手架)。我希望评论既属于用户又属于文章。我的主要问题是:我不知道如何将当前文章的ID放入评论Controller。

  4. ruby - RVM "ERROR: Unable to checkout branch ."单用户 - 2

    我在新的Debian6VirtualBoxVM上安装RVM时遇到问题。我已经安装了所有需要的包并使用下载了安装脚本(curl-shttps://rvm.beginrescueend.com/install/rvm)>rvm,但以单个用户身份运行时bashrvm我收到以下错误消息:ERROR:Unabletocheckoutbranch.安装在这里停止,并且(据我所知)没有安装RVM的任何文件。如果我以root身份运行脚本(对于多用户安装),我会收到另一条消息:Successfullycheckedoutbranch''安装程序继续并指示成功,但未添加.rvm目录,甚至在修改我的.bas

  5. 安卓apk修改(Android反编译apk) - 2

    最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路

  6. ruby - 在没有基准或时间的情况下用 Ruby 测量用户时间或系统时间 - 2

    因为我现在正在做一些时间测量,我想知道是否可以在不使用Benchmark类或命令行实用程序time的情况下测量用户时间或系统时间。使用Time类只显示挂钟时间,而不显示系统和用户时间,但是我正在寻找具有相同灵active的解决方案,例如time=TimeUtility.now#somecodeuser,system,real=TimeUtility.now-time原因是我有点不喜欢Benchmark,因为它不能只返回数字(编辑:我错了-它可以。请参阅下面的答案。)。当然,我可以解析输出,但感觉不对。*NIX系统的time实用程序也应该可以解决我的问题,但我想知道是否已经在Ruby中实

  7. ruby-on-rails - 如何为空白字段编写 rspec? [Rails3.1] - 2

    我使用rails3.1+rspec和factorygirl。我对必填字段(validates_presence_of)的验证工作正常。我如何让测试将该事实用作“成功”而不是“失败”规范是:describe"Addanindustrywithnoname"docontext"Unabletocreatearecordwhenthenameisblank"dosubjectdoind=Factory.create(:industry_name_blank)endit{shouldbe_invalid}endend但是我失败了:Failures:1)Addanindustrywithnona

  8. ruby-on-rails - 使用 javascript 更改数据方法不会更改 ajax 调用用户的什么方法? - 2

    我遇到了一个非常奇怪的问题,我很难解决。在我看来,我有一个与data-remote="true"和data-method="delete"的链接。当我单击该链接时,我可以看到对我的Rails服务器的DELETE请求。返回的JS代码会更改此链接的属性,其中包括href和data-method。再次单击此链接后,我的服务器收到了对新href的请求,但使用的是旧的data-method,即使我已将其从DELETE到POST(它仍然发送一个DELETE请求)。但是,如果我刷新页面,HTML与"new"HTML相同(随返回的JS发生变化),但它实际上发送了正确的请求类型。这就是这个问题令我困惑的

  9. ruby - HTTP 请求中的用户代理,Ruby - 2

    我是Ruby的新手。我试过查看在线文档,但没有找到任何有效的方法。我想在以下HTTP请求botget_response()和get()中包含一个用户代理。有人可以指出我正确的方向吗?#PreliminarycheckthatProggitisupcheck=Net::HTTP.get_response(URI.parse(proggit_url))ifcheck.code!="200"puts"ErrorcontactingProggit"returnend#Attempttogetthejsonresponse=Net::HTTP.get(URI.parse(proggit_url)

  10. ruby-on-rails - capybara poltergeist - 覆盖用户代理 - 2

    有人知道如何将capybarapoltergeist的用户代理覆盖到移动用户代理以进行测试吗?我发现了一些有关为seleniumwebdriver配置它的信息:http://blog.plataformatec.com.br/2011/03/configuring-user-agents-with-capybara-selenium-webdriver/这在capybara闹鬼中怎么可能? 最佳答案 请参阅poltergeistgithub页面上的链接:https://github.com/teampoltergeist/polte

随机推荐