如何poistion程序的EditText android系统? [英] How to poistion edittext in program in android?

查看:179
本文介绍了如何poistion程序的EditText android系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我动态在我的code创建Editext。我想它在定位我的x和y位置在我的code本身在绝对的布局。
谁能帮助我做到这一点。

I am dynamically creating an Editext in my code. i want to position it in my x and y position in my code itself in an absolute layout. can anyone help me to do this.

推荐答案

不要使用AbsoluteLayout。这是pcated德$ P $,只是一个糟糕的主意,因为它会另眼相看对不同DPI的屏幕。考虑使用RelativeLayout的来代替。如果你可以给一个更具体的问题,我们可以推荐一个替代解决方案。

Don't use AbsoluteLayout. It's deprecated, and just a bad idea, as it will look differently on screens with different DPIs. Consider using a RelativeLayout instead. If you can give a more specific problem, we can recommend an alternative solution.

在牢记,你不应该实际使用此,而且使用AbsoluteLayout已经间接地与致癌,也可能导致精神病,这里是你会怎么做这在code假设你有一个AbsoluteLayout在一个XML布局的孩子的EditText:

Keeping in mind that you shouldn't actually use this, and that using AbsoluteLayout has been indirectly linked to causing cancer, and may also lead to psychosis, here is how you would do this in code assuming you have an AbsoluteLayout with a child EditText in an XML layout:

EditText editText = (EditText)findViewById(R.id.my_edit_text);
AbsoluteLayout.LayoutParams abs_params = 
    new AbsoluteLayout.LayoutParams(
        //width in pixels, or AbsoluteLayout.FILL_PARENT/WRAP_CONTENT
        60,
        //height in pixels, or AbsoluteLayout.FILL_PARENT/WRAP_CONTENT
        30,
        //x position with regards to the origin
        10,
        //y position with regards to the origin
        10
    );
editText.setLayoutParams(abs_params);

下面是一些文档页面评论:
http://developer.android.com/reference/android/widget/AbsoluteLayout.LayoutParams.html
http://developer.android.com/reference/android/widget/AbsoluteLayout.html
http://developer.android.com/reference/android/widget/EditText.html

Here are some documentation pages to review: http://developer.android.com/reference/android/widget/AbsoluteLayout.LayoutParams.html http://developer.android.com/reference/android/widget/AbsoluteLayout.html http://developer.android.com/reference/android/widget/EditText.html

我不负责为使用AbsoluteLayout的结果可能发生的任何创伤。愿上帝可怜你的灵魂。 :)

I am not responsible for any trauma that may occur as a result of using an AbsoluteLayout. May god have mercy on your soul. :)

这篇关于如何poistion程序的EditText android系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆