我有RelativeLayout,并且RelativeLayout中有一个textview,我从服务器获取位置,如ALIGN_PARENT_LEFT、ALIGN_PARENT_TOP,基于该值我想更改textview的位置...
我的 xml 文件是......
<?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>
我从以下地方获得了知识以编程方式设置相对布局中 EditText 和 TextView 的位置 https://stackoverflow.com/questions/9094421/set-position-of-an-edittext-and-textview-in-a-relativelayout-programatically改变立场但无法帮助我
任何人都可以帮助我如何动态更改文本视图的位置......
尝试这样
RelativeLayout.LayoutParams params1 = new
RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params1.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
yourTextview.setLayoutParams(params1);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)