多个屏幕的图像按钮大小

时间:2013-12-25 10:11:38

标签: android android-layout size imagebutton

我遇到了android布局的问题,我想制作支持多个屏幕的应用程序,包括平板电脑。 但我对按钮大小有问题。 enter image description here

如何设置图片以适合多种屏幕尺寸? 我在Xdpi Mdpi ldpi的资源中有图片,但似乎eclipse没有使用它们。 此致

我的按钮如下所示:

 <ImageButton
            android:id="@+id/sound4"
            android:layout_width="160dp"
            android:layout_height="81dp"
            android:layout_alignLeft="@+id/sound2"
            android:layout_alignParentRight="true"
            android:layout_alignTop="@+id/sound3"
            android:background="@drawable/famas"
            android:onClick="onClick" />

2 个答案:

答案 0 :(得分:1)

 1)please you can use 9-patch image .so this image will stretch automatically 
   on your device height and width.

使用此链接在线创建9补丁图像.. draw9patch.com

或者您可以使用其他选项:

2)button height and width set in all dimension file in values folder for all devices.

表示x.values-hdpi,values-hdpi,values-mdpi ... etc

答案 1 :(得分:0)

你需要这样做: -

  • 根据您的多个设备创建不同类型的drawable。

    像这样: -

      drawable-hdpi,
      drawable-mdpi,
      drawable-ldpi,
      drawable-xhdpi,
      drawable-xxhdpi,
      drawable-sw600dp
      drawable-large-hdpi,etc.
    

  • 您需要使用此案例的values文件夹。制作不同的维度文件并根据您的设备规范进行设置。

    像这样: -

     values-mdpi,
     values-ldpi,
     values-hdpi,
     values-xxdpi,
     values-xlarge,etc.
    
  • 相关问题