在某个图像附近放置图像按钮

时间:2012-09-16 15:07:58

标签: android position imagebutton

由于设备屏幕尺寸很大,我对ImageButtons在某个图像附近的定位存在问题。可以将所有内容定位为1或2个屏幕尺寸但不能更多,因为它会定位在错误的位置。我已经找到了解决此问题的任何解决方案,并发现可以优化所有图像distances programmatically but a lot of programmmatical properties require 11 API for it. My app should work with 2.2, 2.3 versions too. Another solution is the creating of layout qualifiers but there is some screen sizes where my imageButtons position a bit wrongly and this way demand to create a lot of files, folders. Could you recommend me something interesting in this issue? Something what is more optimal and doesn过多地​​占用设备性能。我尝试实现这张照片http://s018.radikal.ru/i507/1209/07/e3f1024a5780.jpg

<?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>

1 个答案:

答案 0 :(得分:0)

在我看来,你应该为每个屏幕尺寸的设备创建布局(xml)文件,例如layout-small,layout-large,layout-medium。我认为没有这样的方法。