Sen*_*orS 4 android relativelayout android-imageview
我在RelativeLayout的顶部放置了一个ImageView,但图像没有显示在页面顶部.我搜索了互联网并添加android:scaleType="fitStart"了问题并解决了问题,但是图像在页面中获得了更多空间,因为当我在此图像下方添加第二个图像时,第二个图像显示在页面的中心!问题是什么?我怎么解决这个问题?我尝试使用LinearLayout产生相同结果的a.
<?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>
Run Code Online (Sandbox Code Playgroud)
Thanks.Cheers
编辑:和另一个问题如何在EditText下面填充Button 30dp?当我更改Button的PaddingTop时没有改变Button的位置.
// try this
<?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:adjustViewBounds="true"
android:layout_centerHorizontal="true"
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_centerHorizontal="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>
Run Code Online (Sandbox Code Playgroud)