I have a RelativeLayout where I have one TextView
and this element has its android:layout_toLeftOf
attribute set to another TextView in this same layout.
Depending on the data received by the app from the server, I need to set the visibility of this one TextView to GONE
and set the visibility of a ProgressBar
to VISIBLE
and then I need the first TextView left align with this Progress bar.
Is this possible to accomplish programmatically?
If not, could you think of a way to tackle the issue?
EDIT
Following below advice, this is how my working code looks like:
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);
addRule
RelativeLayout.Layoutparams params = (RelativeLayout.LayoutParams)ProgressBar.getLayoutParams();
params.addRule(RelativeLayout.LEFT_OF, R.id.youtTextView);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With