【问题标题】:How To make image botton without effect in android studio如何在android studio中制作没有效果的图像按钮
【发布时间】:2015-12-12 00:58:30
【问题描述】:

我在 content_main.xml 中有 Imagebotton 代码:

<ImageButton
        android:src="@drawable/tri1"
        android:layout_width="110dp"
        android:layout_height="130dp"
        android:id="@+id/imageButtonTri"
        android:layout_marginLeft="75dp"
        />

并显示:

但我想要没有框效果的 imageBotton,例如:

然后,我会让这个 imageBotton 进入下一个布局

我该怎么做???

【问题讨论】:

    标签: java android xml android-studio


    【解决方案1】:
      <ImageButton
            android:src="@drawable/tri1"
            android:layout_width="110dp"
            android:layout_height="130dp"
            android:scaleType="fitCenter"
            android:background="@android:color/transparent"
            android:id="@+id/imageButtonTri"
            android:layout_marginLeft="75dp"
            />
    

    【讨论】:

      【解决方案2】:

      您的图片似乎比提供的尺寸大。如果您使用 wrap_content 而不是固定的高度和宽度,那么您的整个图像将是可见的。像这样的:

      <ImageButton
          android:src="@drawable/tri1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/imageButtonTri"
          android:layout_marginLeft="75dp"
          />
      

      如果您希望图像没有框效果,可以尝试添加透明背景的图像。

      【讨论】:

        【解决方案3】:

        android:src="@drawable/ic_launcher"

        尝试使用

        android:background="@drawable/ic_launcher"
        

        示例:

         <ImageButton
                    android:background="@drawable/ic_launcher"
                    android:layout_width="110dp"
                    android:layout_height="130dp"
                    android:id="@+id/imageButtonTri"
                    android:layout_marginLeft="75dp"
                    />
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2011-09-27
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多