Reputation: 1148
I have an activity that looks like this:
When I run the app on the emulator, the pushpin is not over the post-it note, so I know there will be problems with different sized screens. The post-it note and cork board are the background. How could I go about making it so that, on any sized screen, the pushpin will be at the correct location? It's currently a linear layout.
Upvotes: 0
Views: 56
Reputation: 7708
Based on the above recommendation, do something like this:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:layout_alignParentTop="true"
android:src="@drawable/postit"/>
<ImageButton
android:id="@+id/angry_btn"
android:background="@drawable/pushpin"
android:layout_width="80dp"
android:layout_height="80dp"
android:shadowDx="0"
android:shadowDy="0"
android:layout_gravity="center"
android:shadowRadius="5"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"/>
</RelativeLayout>
Note: You should make the brown part as the background for the outermost layout, and have a separate image for the post-it note, which you should set to the image view I have shown above.
Upvotes: 0
Reputation: 1704
Best solution for you is use a RelativeLayout. I advise that your post-it note not be a part of the background but an own ImageView so that you may re-size it any time to fit any screens. And due to that you can then add this to your code for your cork.
<ImageView
android:id="@+id/cork"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignTop="@+id/postit_note"
/>
It will center the cork in the center and align it to the top of the post-it note.
You may view all the other attributes to help you with RelativeLayouts Here
Upvotes: 1