【问题标题】:how image will fit on button图像如何适合按钮
【发布时间】:2013-12-09 20:01:53
【问题描述】:

我正在开发一个使用按钮的应用程序。在按钮的左侧,我正在使用图像。问题是图像尺寸很大,并且不适合按钮上的尺寸。如何调整图像大小以使其适合按钮。请给我一些解决方案。 xml是这样的。

<LinearLayout
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:layout_marginTop="15dp"
    android:layout_weight="0"
    android:weightSum="1" 
    android:orientation="horizontal" >

 <Button 
     android:id="@+id/btn1" 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:drawableLeft="@drawable/blue" 
     android:gravity="left|center" 
     android:text="Wallpapers"/>
   </Linearlayout>

【问题讨论】:

    标签: android image button


    【解决方案1】:

    尝试使用不同版本的图像并将它们放在正确的文件夹中:

    res/layout/my_layout.xml             // layout for normal screen size ("default")
    res/layout-small/my_layout.xml       // layout for small screen size
    res/layout-large/my_layout.xml       // layout for large screen size
    res/layout-xlarge/my_layout.xml      // layout for extra large screen size
    res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
    
    res/drawable-mdpi/my_icon.png        // bitmap for medium density
    res/drawable-hdpi/my_icon.png        // bitmap for high density
    res/drawable-xhdpi/my_icon.png       // bitmap for extra high density
    

    不过,看看这个http://developer.android.com/guide/practices/screens_support.html 可以帮到你

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-04
      • 1970-01-01
      • 2016-10-15
      • 1970-01-01
      • 2012-04-20
      • 2021-10-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多