I am implementing a custom view, and I have three subviews that I can't get to appear. It seems like the subviews aren't showing; I have set the backgrounds to be red, blue, and green for now to show where I have made set the layout, which is shown in the picture.
I need the subviews to be shown so that the view is complete.
This is the code I'm using in onLayout for the subviews:
backButton.layout(leftOffset, topOffset, leftOffset + seventhWidth, topOffset + seventhWidth);
backButton.setBackgroundColor(Color.RED);
nextButton.layout((int) (leftOffset + calendarWidth - seventhWidth), topOffset, (int) (leftOffset + calendarWidth), topOffset + seventhWidth);
nextButton.setBackgroundColor(Color.GREEN);
monthContainerLayout.layout(leftOffset + thirdWidth, topOffset, (int) Math.round(leftOffset + 2 * thirdWidth), topOffset + seventhWidth);
monthContainerLayout.setBackgroundColor(Color.BLUE);
This is the layout XML for the red square:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
android:id="@+id/back"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:src="@drawable/back_icon"
android:layout_width="wrap_content"
android:layout_height="@dimen/icon_height" />
</RelativeLayout>
This is what the code and layout currently produces (my custom view is only the calendar):
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire