android - RelativeLayout: what's wrong with the baseline alignment? -
i want create layout this:
(the dotted lines baselines of text views.)
so main anchor big w, abc baseline-aligned w, , def above abc.
but when set baseline alignment abc, def falls downwards , gets invisible. there no problem abc, aligned perfectly.
i've found way create def visible: changing alignment abc aligned bottom of w, looks bad because larger glyph has greater bottom margin (more vertical space between baseline , bottom border of view).
it looks baseline alignment handled special way layout cannot calculate right position dependent views.
do wrong? layout ever possible?
here xml:
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <textview android:id="@+id/w" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentright="true" android:layout_alignparenttop="true" android:text="w" android:textappearance="?android:attr/textappearancelarge" android:textsize="100sp" /> <textview android:id="@+id/abc" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbaseline="@+id/w" android:layout_alignparentleft="true" android:text="abc" android:textappearance="?android:attr/textappearancelarge" /> <textview android:id="@+id/def" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/abc" android:layout_alignparentleft="true" android:text="def" android:textappearance="?android:attr/textappearancelarge" /> </relativelayout>
a reasonable not perfect workaround here: https://groups.google.com/d/msg/android-developers/m9thu9v08vo/eouujzv1dtaj
however, led me find little quirk, if align b using simultaneous layout_alignbottom , layout_alignbaseline flags, c’s positioning works, happily sits above b if layout_alignbottom beingness used, although b still aligned a’s baseline. caveat c’s positioning sligthty lower normal; behaves if b aligned a’s bottom, c positioned, , b realigned a’s baseline, without c changing position. can round margin offsets, , @ to the lowest degree can done via xml.
android android-layout
No comments:
Post a Comment