Android 如何设计响应性布局UI视图?

Android 如何设计响应性布局UI视图?,android,android-layout,Android,Android Layout,我想设计一个类似facebook登录页面的登录页面 我已经尝试了下面的布局视图,如果我改变屏幕的方向,底部没有空间,而且我所使用的字段也完全改变了。请建议如何解决这个问题 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/RelativeLayout

我想设计一个类似facebook登录页面的登录页面

我已经尝试了下面的布局视图,如果我改变屏幕的方向,底部没有空间,而且我所使用的字段也完全改变了。请建议如何解决这个问题

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/RelativeLayout1"
    android:layout_width="fill_parent"
  android:layout_height="fill_parent" >

   <ScrollView
       android:id="@+id/ScrollView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true" >

    <LinearLayout
        android:id="@+id/LinearLayout1"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:background="#7CACF5"
        android:orientation="vertical"
        android:padding="10dp"
        android:paddingBottom="30dp" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="70dp"
        android:layout_marginTop="50dp"
        android:gravity="center"
        android:paddingBottom="5dp"
        android:text="Welcome"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="email or phone"
        android:inputType="textEmailAddress"
        android:paddingBottom="5dp" />

    <EditText
        android:id="@+id/editText2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="password"
        android:inputType="numberPassword"
        android:paddingBottom="5dp" >

        <requestFocus />
    </EditText>

    <Button
        android:id="@+id/button1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Log In" />

</LinearLayout>
</ScrollView>
</RelativeLayout>

为此,您需要创建响应式布局,您必须浏览android开发博客,该博客教我们如何创建响应式布局。在basic中,您需要实现不同的Drawables文件夹,如Darawable mdpi、Drawable hdpi、Drawable xhdpi、Drawable xxhdpi和wise,并且您需要将图像放在所有同名但大小不同的文件夹中。同样,您也需要创建布局文件,但xml必须根据您的需求使用适当的属性进行设计


遵循此操作,

除非您另有指定,否则/res/layout中的布局将同时应用于纵向和横向。假设您有/res/layout/login.xml,并且希望它在两种布局类型中看起来有所不同

创建文件夹/res/layoutland(在这里,您将保持您的横向调整布局)。 复制login.xml并对其进行必要的更改。在emulator中运行应用程序,并使用Ctrl+F11组合对其进行测试


//试试这个方法,希望这能帮助你解决问题。。。

您是否尝试过在不同的文件夹中使用不同的布局?(布局横向和布局纵向)您需要使用不同的布局文件夹来实现它。或者您可以使用“权重”属性。是的,我尝试过使用不同的布局文件夹(即res/layout/layout large、res/layout/layout small…),但它不起作用。@swathi但您需要实现res/layout land,您明白我的意思吗?
    <LinearLayout
        android:id="@+id/LinearLayout1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical|center_horizontal"
        android:orientation="vertical"
        android:padding="10dp"
        android:paddingBottom="30dp" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:layout_marginTop="50dp"
            android:gravity="center"
            android:paddingBottom="5dp"
            android:text="Welcome"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:hint="email or phone"
            android:inputType="textEmailAddress"
            android:paddingBottom="5dp" />

        <EditText
            android:id="@+id/editText2"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:ems="10"
            android:hint="password"
            android:inputType="numberPassword"
            android:paddingBottom="5dp" >

            <requestFocus />
        </EditText>

        <Button
            android:id="@+id/button1"
            android:layout_width="match_parent"
             android:layout_height="0dp"
            android:layout_weight="1"
            android:text="Log In" />
    </LinearLayout>
// Try this way,hope this will help you to solve your problem...

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
     android:background="#7CACF5"
    android:gravity="center" >

    <ScrollView
        android:id="@+id/ScrollView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <LinearLayout
            android:id="@+id/LinearLayout1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:padding="10dp" >

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="5dp"
                android:gravity="center"
                android:text="Welcome"
                android:textAppearance="?android:attr/textAppearanceLarge" />

            <EditText
                android:id="@+id/editText1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="5dp"
                android:hint="email or phone"
                android:inputType="textEmailAddress" />

            <EditText
                android:id="@+id/editText2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="5dp"
                android:ems="10"
                android:hint="password"
                android:inputType="numberPassword" >
            </EditText>

            <Button
                android:id="@+id/button1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Log In" />
        </LinearLayout>
    </ScrollView>

</LinearLayout>