我在代码中创建了很多控件,控件的位置是有X、Y坐标来摆放的,在LinearLayout中摆放是发觉它是横着摆放的,并没有按着我想的那样摆放,用RelativeLayout来摆放时它都放在了左上角处。怎么去设置它的摆放位置是我所想的那样。
button.layout(x,y,page.width-x,page.height-y);
这个是我放置它在哪的代码AndroidUI摆放位置

解决方案 »

  1.   

    是不是把用x.y来布局的文件放到AbsoluteLayout布局中才会生效.不过这种布局方式现在已经弃用了
      

  2.   

    那该怎么办呢?我必须得按照X、Y的坐标来布局它
    你先试着把x.y布局控件放在AbsoluteLayout中试试
      

  3.   

    楼主这个问题有点太初学者的水平了,<RelativeLayout
        android:id="@+id/center_lay"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
        <TextView
            android:id="@+id/before_play_loading_txt"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textSize="20px"
            android:gravity="center"
            android:background="#303030"
            android:text="@string/current_status_str" />
             </RelativeLayout>在Textview 中你可以用android:layout_marginTop=""
            android:layout_marginRight=""
            android:layout_marginLeft=""
    来试试效果,自然就知道怎么调节位置了
    android:layout_toRightOf
    android:layout_toLeftOf
    android:layout_below
    等属性