0
由于相当多的设备屏幕大小,我在某个图像附近ImageButtons的位置有问题。可以将所有内容放置1或2个屏幕尺寸,但不能再更改,因为它会定位在错误的位置。我已经找过针对这个问题的任何解决方案,并发现可以优化所有图像设备的性能太多。我尝试实现这个画面http://s018.radikal.ru/i507/1209/07/e3f1024a5780.jpg位置imageButtons在某个图像附近
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rlInjury"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:padding="10dp" >
<ImageView
android:id="@+id/imMonkey"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitCenter"
android:scaleX="0.8"
android:scaleY="0.8"
android:src="@drawable/monkey" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<ImageButton
android:id="@+id/ib1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
android:src="@drawable/pointer1" />
<ImageButton
android:id="@+id/ib2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
android:src="@drawable/pointer3" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<ImageButton
android:id="@+id/ib4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
android:src="@drawable/pointer2" />
<ImageButton
android:id="@+id/ib5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
android:src="@drawable/pointer2" />
</LinearLayout>
</LinearLayout>
我已经尝试过了,例如,如果我将制作布局正常的模板,屏幕大小从3-4英寸变化,那么所有ImageButtons几乎每次都会出现在错误的位置,从3.2英寸到3.3英寸,你会看到另一种观点。可能是,我错误地附加了我的视图元素,这就是为什么它是如此。我会附上一段我的代码。你能推荐我什么会更好地查看它到处都是正确的,因为它只有可能。 – user1376885
然后使用相对布局并对每个视图进行参考,在这里您想将按钮放置在layout_below,layout_left中,而不会出现这种情况 – yokees
我知道相对布局的这种特性,但是如果可以引用人类图片全屏和你的特性可以通过水平,垂直,不同的角落将我的元素对齐,并且几乎都是。也就是说,我可以使用这些属性和margin/padding来精确定位到人体必需的部位。但是,正如我所说的,我将使用具有静态值的边距/填充值,这将不会改变,这取决于屏幕大小。这是一个问题,我发现只有一个好的解决方案 - 某些元素的缩放或更改边距取决于屏幕大小。 – user1376885