我应该创建不同的布局文件夹来存储我的xml布局文件.在不同的屏幕尺寸上支持我的应用程序?
我开发了一个应用程序,当添加drawable时,它会自动创建不同的大小,如xdpi ldpi和更多,但不会自动创建布局xml文件以支持不同的屏幕尺寸.我应该这样做吗?我还将使用支持屏幕标记编辑清单文件以支持不同的大小.这就是全部吗?它还会支持我的风景或肖像模式.请确认一下.我是堆栈和android开发的新手.
编辑:我相信不同文件夹中的不同布局文件..只会是彼此的副本,只有代码中显示的文件夹名称更改广告
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
Run Code Online (Sandbox Code Playgroud)
这是我的布局xml文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/content_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/app_bar_main"
tools:context="com.example.root.meeransunday.MainActivity">
<Button
android:id="@+id/button1"
android:layout_width="200dp"
android:layout_height="90dp"
android:text="Send Mobile"
android:drawableLeft="@mipmap/sms"
android:layout_alignParentBottom="true"
android:layout_marginRight="-1dp"
android:layout_marginLeft="-3dp"
android:layout_marginBottom="-4dp"
android:onClick="message"/>
<Button
android:id="@+id/button2"
android:layout_width="200dp"
android:layout_height="90dp"
android:text="QR Code"
android:drawableLeft="@mipmap/qr"
android:layout_marginLeft="190dp"
android:layout_marginRight="-20dp"
android:layout_marginBottom="-4dp"
android:layout_alignParentBottom="true" …Run Code Online (Sandbox Code Playgroud) 我有一个 xml 屏幕,其中三个子线性布局位于垂直方向的父线性布局中。第一个孩子包含一个图像视图,运行应用程序时我无法查看任何图像。为什么?图片尺寸太大了吗??如果是这样......如何扩展它?但是,可以在我的设计选项卡中查看图像。Android 标准工作室。下面是我的 xml 文件的完整代码。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_sign_up"
android:layout_width="match_parent"
android:layout_height="match_parent"
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="com.example.root.my_laoder.SignUp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:scaleType="centerInside"
android:src="@drawable/ty"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical"
android:paddingTop="50dp"
>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="50dp"
>
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"/>
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
/>
</LinearLayout>
</LinearLayout>Run Code Online (Sandbox Code Playgroud)