我有一个RelativeLayout,其中有一个TextView
元素,它的android:layout_toLeftOf
属性设置为同一布局中的另一个TextView。
根据应用程序从服务器接收到的数据,我需要将此一个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);