11
我有一个RelativeLayout,我有一个TextView
,并且此元素的android:layout_toLeftOf
属性设置为另一个TextView。可以通过编程方式设置android:layout_toLeftOf吗?
根据通过从服务器应用程序接收到的数据,我需要这一个的TextView的可见性设置为GONE
,并设置一个ProgressBar
到VISIBLE
的知名度,然后我需要第一的TextView留下这个进度条对齐。
这是否有可能以编程方式完成?
如果不是,你能想出解决这个问题的方法吗?
非常感谢 费利佩
编辑
以下意见之后,这是我工作的代码看起来像:
TextProgressBar txtProgressBar = (TextProgressBar) v.findViewById(R.id.progressBarPointsInProgress);
TextView offerName = (TextView) v.findViewById(R.id.textViewOfferName);
android.widget.RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)offerName.getLayoutParams();
params.addRule(RelativeLayout.LEFT_OF, R.id.progressBarPointsInProgress);
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
offerName.setLayoutParams(params);
感谢您的支持!
甜!我有一个疑问,虽然:youtTextView被添加到LEFT_OF什么? ProgressBar对象应该与我的布局相同吗? –