滚动型的RelativeLayout的--androidRelativeLayout、android

2023-09-12 22:26:31 作者:无人相候

我有一个RelativeLayout的,我有一些看法(图像和edittexts),现在我想用scrollview.this是我的XML code

i have one RelativeLayout and i have some views(image and edittexts) and now i want to use scrollview.this is a my xml code

<RelativeLayout
    android:id="@+id/relativeLayout2"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_marginTop="70dp" >

    <ImageView
        android:id="@+id/loginbtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/passwordfild"
        android:layout_alignRight="@+id/passwordfild"
        android:layout_below="@+id/passwordfild"
        android:layout_marginTop="28dp"
        android:background="@drawable/login"
        android:textColor="#ffffff" />

    <EditText
        android:id="@+id/passwordfild"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/namefild"
        android:layout_alignRight="@+id/namefild"
        android:layout_centerVertical="true"
        android:background="@drawable/edittextbackground"
        android:ems="10"
        android:hint="პაროლი"
        android:inputType="textPassword"
        android:paddingLeft="15dp"
        android:textColorHint="#e2e0e0" >

        <requestFocus />
    </EditText>

    <EditText
        android:id="@+id/namefild"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/passwordfild"
        android:layout_marginBottom="42dp"
        android:layout_marginLeft="175dp"
        android:layout_marginRight="175dp"
        android:background="@drawable/edittextbackground"
        android:ems="10"
        android:hint="სახელი"
        android:paddingLeft="15dp"
        android:textColorHint="#e2e0e0" >

        <requestFocus />
    </EditText>

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/namefild"
        android:layout_alignLeft="@+id/namefild"
        android:layout_alignRight="@+id/namefild"
        android:layout_marginBottom="100dp"
        android:background="@drawable/icon" />
</RelativeLayout>

此外,我加入

also i added

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginTop="70dp" >

和我插入我的相对布局我的滚动视图内,但设计changed.i不知道我做错了 如果有人知道的解决方案,请帮助我。

and i inserted my relative layout inside my scrollview but design has changed.i have no idea what am i doing wrong if anyone knows solution please help me

推荐答案

不喜欢这样,

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#E0FFFF" >

<TextView
    android:id="@+id/tv1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="15dp"
    android:text="Portal Trading Ltd."
    android:textSize="18sp"
    android:textStyle="italic" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/tvSackNo"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="16dp"
    android:text="Santa Sacks"
    android:textSize="40sp" />

<Button
    android:id="@+id/btnEdit"
    android:layout_width="100dp"
    android:layout_height="60dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:layout_marginRight="21dp"
    android:text="Edit"
    android:textSize="25sp" />

<Button
    android:id="@+id/btnConfirm"
    android:layout_width="100dp"
    android:layout_height="60dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_marginLeft="21dp"
    android:text="Confirm"
    android:textSize="21sp" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/textView2"
    android:gravity="center"
    android:text="Printed Name Details"
    android:textSize="22sp" />

<TextView
    android:id="@+id/tvExtraCharge"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView3"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="5dp"
    android:text="Confirmation Page"
    android:textSize="12sp" />

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/btnEdit"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/tvExtraCharge"
    android:fillViewport="true"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/sackscontainer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center"
        android:orientation="vertical" >

    </LinearLayout>
</ScrollView>