设计在手机上看起来很完美,但在平板电脑上却很小-Android Studio [英] Design looks perfect on phone but so small on tablet - android studio

查看:107
本文介绍了设计在手机上看起来很完美,但在平板电脑上却很小-Android Studio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的android项目制作了这个xml文件,该设计在我的手机上看起来很完美,但是在平板电脑上运行它可以使按钮,图像等看起来很小,我希望根据它们的大小进行更改设备正在运行.

I made up this xml file for my android project, the design looks perfect on my phone but running it on my tablet makes buttons, images,... look so small, i would love to make their size change according to the device running on.

这是我的xml文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background"
    android:fitsSystemWindows="true"
    tools:context="molfix.dev.molfix.Activities.Bvn.BienvenuActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:background="#91d0f0"
        android:layout_height="wrap_content">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="45dp"
            android:background="@drawable/toolbar_bvn"
            android:scrollbars="none"
            app:popupTheme="@style/AppTheme.PopupOverlay"
            android:weightSum="1">
        </android.support.v7.widget.Toolbar>

    </android.support.design.widget.AppBarLayout>

    <Button
        android:layout_width="250dp"
        android:layout_height="55dp"
        android:layout_marginLeft="30dp"
        android:layout_marginRight="30dp"
        android:background="@drawable/button_inscrip"
        android:id="@+id/b_inscrip"
        android:layout_marginTop="20dp"
        android:layout_below="@+id/b_connex"
        android:layout_centerHorizontal="true" />

    <Button
        android:layout_width="250dp"
        android:layout_height="55dp"
        android:background="@drawable/button_connex"
        android:id="@+id/b_connex"
        android:layout_marginTop="151dp"
        android:layout_below="@+id/appbar"
        android:layout_alignStart="@+id/b_inscrip" />
</RelativeLayout>

推荐答案

您必须为多屏幕设计xml.对于受支持的选项卡,您应该创建layout-sw600dp布局,这将支持7英寸的平板电脑,对于10英寸的平板电脑,请创建layout-sw720dp.在res文件夹中创建这些布局后,将xml复制并粘贴到该文件夹​​中,并根据需要提供视图的大小.

You have to design your xmls for multi screens. For tab supported, you should create layout-sw600dp layout, this will support 7 inch tablets and for 10 inch tablet create layout-sw720dp. After creating those layouts in res folder copy and paste your xmls in that folders and give sizes for views according to your requirement.

这篇关于设计在手机上看起来很完美,但在平板电脑上却很小-Android Studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆