android - Correct RelativeLayout usage please -
i have layout listview item , it's displayed incorrectly (book descr goes on last update date). can please me fix?
if set
android:layout_above="@+id/lastupdateddt"
to bookdescr item whole text disappears...
edit: i've updated sample according comments
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <relativelayout android:layout_width="match_parent" android:layout_height="match_parent" android:descendantfocusability="blocksdescendants" android:layout_margin="10dp" android:background="@drawable/big_card_details" android:clickable="true" android:focusable="false"> <checkbox android:id="@+id/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" style="?android:attr/starstyle" android:layout_margintop="10dp" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:layout_marginleft="10dp" /> <textview android:id="@+id/booktitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="book title" android:textsize="16sp" android:layout_alignbaseline="@id/icon" android:layout_alignparenttop="true" android:layout_torightof="@id/icon" /> <textview android:id="@+id/booksize" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" android:text="470k" android:layout_alignbaseline="@id/icon" android:textsize="16sp" android:layout_alignparentright="true" android:layout_marginright="10dp" /> <textview android:id="@+id/lastupdateddt" android:layout_width="match_parent" android:layout_height="26dip" android:singleline="true" android:text="updated 27.04.2014 17.10" android:textsize="12sp" android:layout_alignparentright="true" android:layout_alignparentend="true" android:layout_alignparentbottom="true" android:layout_alignleft="@id/icon" /> <textview android:id="@+id/bookdescription" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleline="false" android:textsize="10sp" android:text="here should long description" android:layout_alignend="@id/booksize" android:layout_below="@+id/booktitle" android:layout_margintop="20dp" android:layout_alignleft="@+id/icon" /> <!-- button trigger sliding of expandable view --> <imagebutton android:id="@+id/expand_details_button" android:src="@drawable/slide_button_details" android:layout_aligntop="@id/lastupdateddt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@null" android:layout_alignbaseline="@id/lastupdateddt" android:layout_alignparentbottom="true" android:layout_alignright="@id/booksize" android:layout_alignend="@id/booksize" /> </relativelayout> <!-- expandable view hidden , slide out when more button pressed --> <linearlayout android:id="@+id/details_expandable" android:layout_width="match_parent" android:layout_height="wrap_content" android:baselinealigned="false" android:orientation="horizontal" > <!-- put whatever want in expandable view --> <button android:layout_width="match_parent" android:layout_weight="0.3" android:drawabletop="@drawable/ic_action_read" android:text="@string/readbook" style="@style/slidebuttontheme" /> <button android:layout_width="match_parent" android:layout_weight="0.3" android:drawabletop="@drawable/ic_action_open_browser" style="@style/slidebuttontheme" android:text="@string/openinbrowser" /> </linearlayout> </linearlayout>
hope aware child view in relativelayout
need placed below/above of sibling views
or aligned parent
.
the problem here , lastupdateddt
aligned parent bottom
, since parent relativelayout
height set wrap_content
height decided based on child views , lastupdateddt
placed @ bottom depends on parent height, overlap sibling view.
fix : set android:layout_below="@+id/bookdescription"
lastupdateddt
textview
, lastupdateddt
placed bottom of parent , below bookdescription
textview
sibling.
Comments
Post a Comment