2012-03-14 86 views
2

我遇到了Android ImageButton的问题。 我的图标在顶部被切断。Android ImageButton削减图标顶部

代码如下:

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:gravity="center" 
    android:orientation="horizontal" 
    android:layout_marginBottom="20sp" 
    android:paddingLeft="20sp" 
    android:paddingRight="20sp" > 

    <TextView 
     android:id="@+id/registration_1_button_sex_male_title" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/registration_1_male" 
     android:textColor="#fff" 
     android:textSize="15sp" 
     android:typeface="monospace" /> 

    <ImageButton 
     android:id="@+id/registration_1_button_sex_male" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@android:color/transparent" 
     android:paddingRight="20sp" 
     android:src="@drawable/icon_male_blue" /> 
</LinearLayout> 

我已经试过这我GOOGLE了,但没有人帮助一些黑客。

+0

我也试图在LinearLayout和ImageButton里面添加填充,但没有帮助,我尝试给图标和LinearLayout一个固定的高度,但没有任何工作。 – kjurkovic 2012-03-14 09:42:38

+0

你可以发布图像? – Tony 2012-03-14 10:29:57

回答

0

尝试增加:

android:scaleType="fitCenter" 

您的ImageButton

如果失败尝试下scaleType属性的其他选项

+0

我尝试了ScaleType的所有选项..仍然是同样的问题 – kjurkovic 2012-03-14 09:51:34

+0

你试过移动图标吗?我有时在drawable-hdpi/ldpi中发现了奇怪的行为,并且恢复为只创建一个“drawable”文件夹。 – Tony 2012-03-14 09:53:58

+0

我试着移动它..它仍然是一样的:\ – kjurkovic 2012-03-14 09:59:24

1

尽量保持图像的Android:背景,而不是机器人:SRC在的ImageButton。它不是解决所有问题的解决方案,但对这类问题起到很好的作用。