你好我正在开发“鼓应用程序”应用程序,我希望应用程序看起来像真正的鼓,所以,在主屏幕上我有鼓组的背景和背景我有一些图像按钮与鼓垫我之前在photoshop中剪切它:
现在,当我试图将“ImageButtons”放到正确的位置时,它在一台设备上看起来不错,但在另一台设备上看起来像是这样:
这是我的代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/drums" />
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="200dp"
android:layout_marginTop="30dp"
android:background="@android:color/transparent"
android:src="@drawable/image2" />
<ImageButton
android:id="@+id/imageButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:layout_marginTop="50dp"
android:background="@android:color/transparent"
android:src="@drawable/image3" />
<ImageButton
android:id="@+id/imageButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="93dp"
android:layout_marginTop="13dp"
android:background="@android:color/transparent"
android:src="@drawable/image4" />
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="235dp"
android:layout_marginTop="95dp"
android:background="@android:color/transparent"
android:src="@drawable/image1" />
</FrameLayout>
</LinearLayout>
我该怎样处理?我想我做了什么! 是这样思考的正确方法吗?
答案 0 :(得分:0)
嗯,你的方式可能不是解决这个问题的正确方法。首先,如果您想要将您的观点相对于其他观点定位,请使用RelativeLayout
- http://developer.android.com/guide/topics/ui/layout/relative.html
其次你应该为不同的密度提供不同的鼓png文件:http://developer.android.com/training/multiscreen/screendensities.html#TaskProvideAltBmp。阅读提供不同的png部分。
第三,你应该真正阅读Designing for Multiple Screens
指南:http://developer.android.com/training/multiscreen/index.html
如果您有任何其他问题,请不要犹豫。