Reputation: 197
I'm trying to put the ImageView at the center of my screen between the bottom of my LinearLayout and the bottom of my App, I tried to use id without success.
This is a image of what i search to do:
So I want to place the cookie between 1 and 2
This is my code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg"
tools:context=".MainActivity">
<ImageView
android:id="@+id/cookie"
android:layout_width="240dp"
android:layout_height="240dp"
android:src="@drawable/cookie2"
android:layout_centerHorizontal="true"
android:layout_below="@id/layout"
/>
<LinearLayout
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="#6000"
android:layout_gravity="center_horizontal"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/click"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/cookie_msg"
android:textColor="@color/whiteColor"
android:fontFamily="@font/kavoon"
android:textSize="24sp"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/kavoon"
android:gravity="center"
android:text="@string/cps_msg"
android:textColor="@color/whiteColor"
android:textSize="15sp" />
</LinearLayout>
Upvotes: 0
Views: 41
Reputation: 1119
This should do the trick
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/layout"
android:gravity="center">
<!--wrap image view inside this linear layout-->
<ImageView
android:id="@+id/cookie"
android:layout_width="240dp"
android:layout_height="240dp"
android:src="@drawable/cookie2"/>
</LinearLayout>
<LinearLayout
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="#6000"
android:layout_gravity="center_horizontal"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/click"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/cookie_msg"
android:textColor="@color/whiteColor"
android:fontFamily="@font/kavoon"
android:textSize="24sp"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/kavoon"
android:gravity="center"
android:text="@string/cps_msg"
android:textColor="@color/whiteColor"
android:textSize="15sp" />
</LinearLayout>
</RelativeLayout>
Upvotes: 1