Android layout 这款设计在手机上看起来很完美,但在平板电脑上太小了-安卓工作室
我为我的android项目制作了这个xml文件,这个设计在我的手机上看起来很完美,但在我的平板电脑上运行它会生成按钮、图像,。。。看起来这么小,我很想让他们的大小根据设备上运行的变化 这是我的xml文件:Android layout 这款设计在手机上看起来很完美,但在平板电脑上太小了-安卓工作室,android-layout,android-studio,Android Layout,Android Studio,我为我的android项目制作了这个xml文件,这个设计在我的手机上看起来很完美,但在我的平板电脑上运行它会生成按钮、图像,。。。看起来这么小,我很想让他们的大小根据设备上运行的变化 这是我的xml文件: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://sc
<?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。对于支持的选项卡,您应该创建布局-sw600dp布局,这将支持7英寸平板电脑,对于10英寸平板电脑,创建布局-sw720dp。在res文件夹中创建这些布局后,将XML复制并粘贴到该文件夹中,并根据您的要求给出视图的大小。您可以尝试使用可缩放dp而不是dp/sp等。这将根据设备上运行的情况调整视图的大小
依赖关系:-
compile 'com.intuit.sdp:sdp-android:1.0.2'
这样使用:-
将xml中的所有“10dp”(您的dp值)替换为“dimen/_10sdp”(根据您的dp值进行更改)。它对我不起作用,我是这样使用的:在values文件夹中的dimens.xml文件中,我插入了这个55sdp,在我的activity_main.xml中,我使用了这一行,就像android:layout\u height=“@dimen/_20sdp”代替android:layout_height=“20dp”。无需将其添加到dimens.xml中。我不知道如何在res文件夹中创建这些文件??!右键单击res文件夹,单击新建->单击布局资源文件,命名为layout-sw600dp,同时创建layout-sw720dp。之后,将布局xmls文件复制到这些文件夹layout-sw600dp和layout-sw720dp中。根据您的要求应用视图大小。