【问题标题】:Android 9-patch and drawable-mdpiAndroid 9-patch 和 drawable-mdpi
【发布时间】:2012-06-01 17:26:49
【问题描述】:

我为 Android 创建了一个简单的 9-patch 图像。倒入文件夹drawable-mpdi。一切正常,但上框架丢失了。目前尚不清楚为什么。见截图:

这是我的 9 补丁文件:

https://dl.dropbox.com/u/30086473/input_login_active2.9.png

我的 XML 布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/white">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:background="@drawable/login_bg"
        android:orientation="vertical">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/auth_logo"/>
            <EditText
                android:layout_width="273dip"
                android:id="@+id/login"
                android:layout_marginTop="20dip"
                android:layout_height="wrap_content"
                android:background="@drawable/auth_edit_text"
                android:hint="@string/auth_login"/>
            <EditText
                android:layout_width="273dip"
                android:id="@+id/password"
                android:layout_height="wrap_content"
                android:background="@drawable/auth_edit_text_left"
                android:hint="@string/auth_login_left"
                android:layout_marginLeft="17dip"/>
    </LinearLayout>
</LinearLayout>

有什么问题?如何回收9-patch,元素上方有蓝框?

有@drawable/auth_edit_text:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/t" />
</selector>

【问题讨论】:

  • 我看不到您的布局引用drawable/input_login_active2 的位置。是从drawable/login_bg 进来的吗?如果是这样,请为此发布xml。
  • 是的。我在问题文本中添加@drawable/auth_edit_text

标签: android drawable nine-patch


【解决方案1】:

您的像素边框似乎不正确(可能颠倒了)。试试这个:

使用您的原件,您还可以拉伸电话图标,而不仅仅是气泡。此外,您将顶部和底部的内容区域和拉伸区域颠倒了(我在附件中将它们颠倒了)。虽然我不知道这会具体导致您显示的问题,但我会尝试一下,看看会发生什么。

编辑:试试这个:

来自评论的编辑答案:我认为您的问题可能是它正在寻找 ldpi 图像,没有找到,然后回退到默认值并缩小它。由于边框只有 1 px,因此在缩小时它会消失。

【讨论】:

  • 是的,我同意你的版本更好,但它并没有解决问题(我现在尝试了 - 我看到了相同的结果。我完全混乱 - 屏幕上唯一的问题分辨率,我们有截图。在 hdpi 上,xhdpi 一切正常!有任何变体吗?
  • 我有一个想法:尝试将文本框设置为 2 行长,看看问题是否仍然存在。如果它适用于 2 行,我想我知道这个问题。
  • 是的,如果文本框中有 2 行 - 问题也存在。以及 3、4 和其他行数 - 问题仍然存在。
  • 如果有 2 行 - 底框也会丢失
  • 这很奇怪。你确定设备是mdpi?另外,我注意到您输入了drawable-mpdi 作为您放入的文件夹——我确定这只是一个错字,但请确保它是drawable-mdpi,因为看起来您正在进行一些意外的缩放。我将在另一个版本中进行编辑,我认为您应该尝试。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-18
  • 1970-01-01
  • 1970-01-01
  • 2012-02-08
  • 1970-01-01
相关资源
最近更新 更多