Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 首次发布时的帮助器屏幕(9-patch)_Android_Android Layout_Android Ui_Nine Patch - Fatal编程技术网

Android 首次发布时的帮助器屏幕(9-patch)

Android 首次发布时的帮助器屏幕(9-patch),android,android-layout,android-ui,nine-patch,Android,Android Layout,Android Ui,Nine Patch,我正在尝试为应用程序的首次启动开发一个帮助屏幕。为了在所有尺寸的设备上完成这项工作,我制作了一个9patch文件(不要看设计,它完全是原始的。我只想为设计师做一个概念证明) 如您所见,我想(根据屏幕大小)在垂直方向上重复左边的空格,在水平方向上重复“Swipe to”和“you have done”之间的空格 我已将png放在hdpi文件夹中,我的活动包含以下资源布局: <RelativeLayout xmlns:android="http://schemas.android.com/a

我正在尝试为应用程序的首次启动开发一个帮助屏幕。为了在所有尺寸的设备上完成这项工作,我制作了一个9patch文件(不要看设计,它完全是原始的。我只想为设计师做一个概念证明)

如您所见,我想(根据屏幕大小)在垂直方向上重复左边的空格,在水平方向上重复“Swipe to”和“you have done”之间的空格

我已将png放在hdpi文件夹中,我的活动包含以下资源布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/helper"
        android:scaleType="fitXY" />
</RelativeLayout>

以下是720px大图片的结果:

下面是一张480px大图片的结果:

以下是一张240px大图片的结果:

我想我必须使用一个好的维度和ldpi/mdpi/hdpi/xhdpi文件夹,也许还需要使用衍生的ldpi landscap/mdpi景观

有没有办法把它做好?我的形象应该有什么维度


提前谢谢

我认为您应该检查此自定义视图:


它将以一种更简单、更轻松、更兼容的方式完成您需要实现的目标。

正如托马斯·克莱森所建议的,我所做的不是4张而是2张图片:

  • 顶部:2个箭头和相应的文本
  • 底部:“切换至显示”和“点击以关闭”
以下是我的“测试”布局:



我仍然有一些问题的顶部区域时,它的大小,它不适合右上角

我不知道你问题的答案。然而,我不明白你为什么要让它变得困难,并使用9patch图像。你不能把覆盖图分成4张图片吗。一个是半透明的灰色背景,另外三个是不同的箭头/注释。通过这种方式,你将能够正确地居中底部位,并按照你的意愿在所有方向上布局你的图像。你需要创建多个具有不同分辨率的图像,以适应所有屏幕sizes@ThomasClayson因为9-patch是针对这种情况完成的(用于匹配所有设备大小的可扩展区域)。我建议您将您的信息作为答案,如果我的9-patch文件没有解决方案,我将接受。@Hrk不,9-patch用于可扩展区域,但不匹配所有设备大小。它们用于具有可变文本的按钮,或具有可变大小的输入区域,可能用于需要拉伸的视图背景。不是针对不同的屏幕大小,这就是为什么你有不同的可绘制文件夹。谢谢,我知道这个库,但现在没有对操作栏按钮的支持,它似乎很难实现。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/my_translucent_background_color" >

<ImageView
    android:id="@+id/imageview_top"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/helper_top"
    android:paddingLeft="20dp"
    android:layout_weight="1"
    android:layout_gravity="top|right" />

<ImageView
    android:id="@+id/imageview_bottom"
    android:layout_width="400dp"
    android:layout_height="wrap_content"
    android:paddingLeft="20dp"
    android:paddingRight="20dp"
    android:src="@drawable/helper_bottom"
    android:layout_weight="2"
android:layout_gravity="bottom|center_horizontal" />