在Android按钮中展平或缩小图像

在Android按钮中展平或缩小图像,android,android-studio,android-button,Android,Android Studio,Android Button,我使用的是Android Studio,我的绘图文件夹中有一个.png图像,所有格式(hdi、ldpi等), 问题是,当我运行应用程序时,我将按钮背景设置为可绘制图像。图像似乎变平或缩小。我不知道为什么会发生这种情况,并且在我以前的ADT包中从未遇到过问题 这是我的布局文件 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.an

我使用的是Android Studio,我的绘图文件夹中有一个.png图像,所有格式(hdi、ldpi等), 问题是,当我运行应用程序时,我将按钮背景设置为可绘制图像。图像似乎变平或缩小。我不知道为什么会发生这种情况,并且在我以前的ADT包中从未遇到过问题

这是我的布局文件

<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"
    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=".MainActivity">

    <TextView
        android:id="@+id/splash_screen_appname"
    android:typeface="serif"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="40dp"
        android:gravity="center"
        android:text="@string/app_name"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textSize="35sp" />

    <TextView
        android:id="@+id/splash_screen_version"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:typeface="serif"
        android:layout_alignEnd="@+id/splash_screen_quotes"
        android:layout_alignRight="@+id/splash_screen_quotes"
        android:layout_below="@+id/splash_screen_appname"
        android:text="Version 9.0"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <TextView
        android:id="@+id/splash_screen_quotes"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_centerVertical="true"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp"
        android:gravity="center"
        android:typeface="serif"
        android:text="“when you don&apos;t create things, you become defined by your tastes rather than ability. your tastes only narrow &amp; exclude people. so create.” "
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/splash_screen_companyname"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:text="By - Intralane"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/splash_screen_continue"
        android:background="@drawable/ic_action_next"
        android:layout_above="@+id/splash_screen_companyname"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="58dp" />


</RelativeLayout>

这是图像或屏幕快照

这是drawable文件夹中的原始.png文件(图像)


PS:这个问题通常出现在平台3.0+,在AVD2.3中,它很好,图像是圆形的,我在以前的项目中使用了圆形。png图像如上所示,即使在平台3.0+中使用ADT Bundle,它们也没有类似的问题

尝试使用分辨率更高的图像,或者你可以用imageView代替image按钮,并将按钮的比例类型设为“fitXY”。为什么不用imageView代替按钮呢?所有按钮都有同样的问题views@krunalpatel它的分辨率更高,工作正常一次,有时(大多数)会出现此错误尝试使用imageView并将imageView的比例类型添加到“fitxy”