变化的TextView的位置动态地使用Java在RelativeLayout的机器人 [英] Change TextView's position dynamically using java in RelativeLayout android
问题描述
我有RelativeLayout的,并且有在RelativeLayout的一个TextView,我是来自像ALIGN_PARENT_LEFT,ALIGN_PARENT_TOP,根据该值我想改变TextView的位置服务器获取位置...
i have RelativeLayout, and there is a textview in the RelativeLayout, i am getting position from server like ALIGN_PARENT_LEFT, ALIGN_PARENT_TOP, based on that value i want to change position of textview...
我的XML文件....
My xml file is....
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:id="@+id/relativelayout"
android:orientation="vertical" >
<TextView
android:id="@+id/share_text"
android:layout_width="100dp"
android:layout_height="60dp"
android:gravity="center"
android:background="@drawable/share_text" />
</RelativeLayout>
我从<一个有知识href=\"http://stackoverflow.com/questions/9094421/set-position-of-an-edittext-and-textview-in-a-relativelayout-programatically\">Set在RelativeLayout的一个EditText TextView的和位置的编程以恰克的位置,但不能帮我。
i have got knowledge from Set position of an EditText and TextView in a RelativeLayout programatically to chage the position but couldn't help me
任何机构可以帮助我如何改变TextView的位置动态...
can any body help me how to change position of textview dynamically...
推荐答案
试试这样
RelativeLayout.LayoutParams params1 = new
RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params1.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
yourTextview.setLayoutParams(params1);
这篇关于变化的TextView的位置动态地使用Java在RelativeLayout的机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!