android - Can't align element with toStartOf in a RelativeLayout -
basically have numberpicker
aligned right, imageview
aligned top left, , 2 buttons in linearlayout
container trying align left of picker , bottom of parent. no success. container takes whole space overlapping picker.
<relativelayout android:id="@+id/cell_1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:animatelayoutchanges="true" android:background="@color/blue_light" android:padding="@dimen/spacing_tiny"> <numberpicker android:id="@+id/np_1" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_alignparentend="true" android:layout_margin="@dimen/spacing_tiny" android:visibility="visible" /> <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:layout_alignparenttop="true" android:layout_margin="@dimen/spacing_tiny" /> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_tostartof="@+id/np_1" android:orientation="vertical" android:visibility="visible"> <button style="@style/largeholobutton.secondarybutton" android:layout_width="match_parent" android:layout_height="0dp" android:layout_margin="@dimen/spacing_tiny" android:layout_weight="1" android:minwidth="0dp" android:text="@string/button.updown" /> <button style="@style/largeholobutton.secondarybutton" android:layout_width="match_parent" android:layout_height="0dp" android:layout_margin="@dimen/spacing_tiny" android:layout_weight="1" android:minwidth="0dp" android:text="@string/button.leftright" /> </linearlayout> </relativelayout>
starting api level 17 cannot use layout_tostartof
. should use
android:layout_toleftof="@+id/np_1"
again api 17 cannot use 'layout_alignparentend'. instead use
android:layout_alignparentright="true"
and have error relativelayout width set '0dp'. make match_ parent
.
the corrected code below you
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/cell_1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:animatelayoutchanges="true" android:background="#000099" android:padding="8dp"> <numberpicker android:id="@+id/np_1" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_alignparentright="true" android:layout_margin="8dp" android:visibility="visible" /> <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:src="@mipmap/ic_launcher" android:layout_alignparenttop="true" android:layout_marginleft="8dp" android:layout_margintop="8dp" android:layout_above="@+id/linearlayout" android:layout_toleftof="@+id/np_1" android:layout_tostartof="@+id/np_1" /> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_toleftof="@+id/np_1" android:orientation="vertical" android:visibility="visible" android:id="@+id/linearlayout"> <button android:layout_width="match_parent" android:layout_height="0dp" android:layout_margin="8dp" android:layout_weight="1" android:minwidth="0dp" android:text="assafsasaf" /> <button android:layout_width="match_parent" android:layout_height="0dp" android:layout_margin="8dp" android:layout_weight="1" android:minwidth="0dp" android:text="sadsadsadsa" /> </linearlayout> </relativelayout>
and looks below image (set colour , padding yours)
Comments
Post a Comment