【问题标题】:how can i resize imageButton?如何调整 imageButton 的大小?
【发布时间】:2013-01-26 05:28:49
【问题描述】:

我想在图形布局上使用鼠标或使用代码来调整 ImageButton 的大小 android:layout_widthandroid:layout_height。但每当我这样做时,ImageButton 不会调整大小,事实上它并没有更小,而是在边缘被切割。

提前致谢

【问题讨论】:

    标签: android resize imagebutton


    【解决方案1】:

    首先尝试使用 android:background 而不是 android:src 来设置按钮上的图像。在大多数情况下,它会有所帮助。如果没有,请查看这些..

    【讨论】:

      【解决方案2】:
          <ImageButton
              android:layout_width="48dp"
              android:layout_height="48dp"
              android:background="@drawable/ic_star_border"
          />
      or
             <ImageButton
                  android:layout_width="36dp"
                  android:layout_height="36dp"
                  android:background="?selectableItemBackgroundBorderless"
                  android:scaleType="fitXY"
                  android:src="@drawable/ic_delete" />
      

      【讨论】:

        【解决方案3】:

        您必须为按钮指定固定尺寸(使用dp 而不是px)。示例:

        <ImageButton 
          android:background="@drawable/ic_menu_more" 
          android:layout_width="50dip" 
          android:layout_height="50dip" 
        />
        

        【讨论】:

          【解决方案4】:

          这可能是您的图像大小的问题..尝试使用调整大小的图像然后在您的图像按钮中使用它。然后您可以设置按钮的宽度和高度。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2013-11-03
            • 1970-01-01
            • 2021-02-24
            • 2020-11-16
            相关资源
            最近更新 更多