Why Mytextview In Android Is Not Aligned To Right?
<com.me.view.text.MyTextView
android:id="@+id/tipText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tipTitleLayout"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:maxLines="4"
android:text="Navigation . everything else you need is here"
android:textColor="#000000"
android:layout_alignParentRight="true"
android:textSize="16dp" />
Solution 2:
From your question, it seems that you want to do it dynamically. Try this,
Try to call title.requestLayout()
, when you are setting the specifications for textview.
Solution 3:
If you want to add the text view at the right side of your parent layout then try this:
<RelativeLayoutandroid:id="@+id/ShortTextTip"android:layout_width="150dp"android:layout_height="200dp"android:background="@android:color/holo_purple"android:gravity="center"android:paddingBottom="7dp"android:paddingLeft="7dp"android:paddingRight="7dp"android:paddingTop="6dp"android:layout_alignParentLeft="true"android:visibility="visible"><TextViewandroid:id="@+id/tipText"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@+id/tipTitleLayout"android:layout_alignParentRight="true"android:layout_marginLeft="5dp"android:layout_marginRight="5dp"android:layout_marginTop="10dp"android:maxLines="4"android:text="Navigation . everything else you need is here"android:textColor="#000000"android:textSize="16dp" /></RelativeLayout>
And if you want to right-align of the text in the textView as well then add it in your textView:
android:gravity="right"
And if you want to do it programatically:
View aa = (View) your_textView.getParent();
aa.setGravity(Gravity.RIGHT);
Post a Comment for "Why Mytextview In Android Is Not Aligned To Right?"