I have chat list view in which sender name should be left aligned and receiver's reply should be on right side, and then vice a versa when receiver becomes sender.
Here is my xml file:
<?xml version="1.0" encoding="utf-8"?>
<TextView android:id="@+id/chatmessagename"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:textSize="16sp" android:textStyle="bold"
android:paddingBottom="1dp" />
<TextView android:id="@+id/chatmessagedate"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:autoLink="none" />
<TextView android:id="@+id/chatmessagetext"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/chatmessagename"
android:autoLink="all" />
Now at runtime i want to change textview's layout_alignParentRight value. Is it possible to do ?
Try:
...
RelativeLayout.LayoutParams layoutParams =(RelativeLayout.LayoutParams)yourView.getLayoutParams();
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_.....); //ALIGN_PARENT_RIGHT / LEFT etc.
yourView.setLayoutParams(params);
...
yes is possible you can use this things:-
RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(
android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT,
android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);
rlp.addRule(RelativeLayout.ALIGN_RIGHT,
textviewid);
form this code you get some ref..
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