I placed the ImageView at the top of the RelativeLayout, but the image does not appear at the top of the page. I searched the Internet and I added android:scaleType="fitStart"
and the problem was solved, but the image gets more space on the page, because when I add a second image below this image, the second image is displayed in the center of the page! What is the problem? How can i solve this? I tried using LinearLayout
, which gives the same result.
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:id="@+id/registerAction" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:scaleType="fitStart" android:src="@drawable/register_action" /> <ImageView android:id="@+id/registerLogo" android:src="@drawable/app_pass" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:layout_below="@id/registerAction"/> <EditText android:id="@+id/pass1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/registerLogo" android:paddingTop="15dp" android:layout_marginRight="10dp" android:layout_marginLeft="10dp" android:inputType="textPassword" android:hint="@string/pass1" android:gravity="right"/> <EditText android:id="@+id/pass2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/pass1" android:paddingTop="15dp" android:layout_marginRight="10dp" android:layout_marginLeft="10dp" android:inputType="textPassword" android:hint="@string/pass2" android:gravity="right"/> <Button android:id="@+id/btn" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/pass2" android:paddingRight="10dp" android:paddingLeft="10dp" android:paddingTop="30dp"/> </RelativeLayout>
Thanks.Cheers
EDIT: and one more question. How can I add a 30dp button below in an EditText? When I changed the PaddingTop button, the button position did not change.
source share