Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何使一个相对布局的应用程序在没有太多代码更改的情况下响应?_Android_Android Layout - Fatal编程技术网

Android 如何使一个相对布局的应用程序在没有太多代码更改的情况下响应?

Android 如何使一个相对布局的应用程序在没有太多代码更改的情况下响应?,android,android-layout,Android,Android Layout,我有一个相对布局的应用程序,里面有: 1) 一种垂直线性布局,具有一个开关和2个编辑文本 2) 水平线性布局,位于垂直布局下方,带有两个按钮 它在galaxy A8手机上运行良好,但在小屏幕手机上,底部的水平线性布局重叠 我需要一些关于如何在没有太多代码更改的情况下使其响应性的指导,因为我的界面设计技术非常差 谢谢你的帮助 我试图将其转换为约束布局,但它使我的用户界面更糟糕。应用程序停止响应 <?xml version="1.0" encoding="utf-8"?> <Rel

我有一个相对布局的应用程序,里面有:

1) 一种垂直线性布局,具有一个开关和2个编辑文本

2) 水平线性布局,位于垂直布局下方,带有两个按钮

它在galaxy A8手机上运行良好,但在小屏幕手机上,底部的水平线性布局重叠

我需要一些关于如何在没有太多代码更改的情况下使其响应性的指导,因为我的界面设计技术非常差

谢谢你的帮助

我试图将其转换为
约束布局
,但它使我的用户界面更糟糕。应用程序停止响应

<?xml version="1.0" encoding="utf-8"?>
<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:orientation="vertical"
    tools:context=".MainActivity"
    android:animateLayoutChanges="true"
    android:clipChildren="false">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="15dp">

        <Switch
            android:id="@+id/switch1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:text="French to English"
            android:textSize="18sp"
            android:checked="true"
            android:thumbTint="@color/colorPrimary"
            android:trackTint="@color/colorAccent" />

        <EditText
            android:id="@+id/pname"
            android:layout_width="match_parent"
            android:layout_height="225dp"
            android:layout_marginTop="15dp"
            android:maxLength="100"
            android:background="@drawable/rounded_border_edittext"
            android:ems="15"
            android:gravity="top"
            android:hint="Enter your text to translate here..."
            android:inputType="textMultiLine"
            android:padding="10dp" />

        <EditText
            android:id="@+id/target"
            android:layout_width="match_parent"
            android:layout_height="225dp"
            android:layout_marginTop="30dp"
            android:maxLength="100"
            android:background="@drawable/rounded_border_edittext1"
            android:ems="15"
            android:gravity="top"
            android:hint="Your translated text will appear here..."
            android:inputType="textMultiLine"
            android:padding="10dp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:orientation="horizontal"
        android:padding="15dp">

        <Button
            android:id="@+id/btnsave"
            style="@style/Widget.AppCompat.Button.Colored"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Save" />

        <Button
            android:id="@+id/btntranslate"
            style="@style/Widget.AppCompat.Button.Colored"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Translate" />
    </LinearLayout>
</RelativeLayout>

尝试将垂直线性布局中的两个编辑文本的高度设置为190dp

android:layout_height="190dp"
还有他们的边际价值到15dp

android:layout_marginTop="15dp"

这将符合Android设备的最小屏幕尺寸,即426x320

非常感谢,现在这两款手机都可以使用。TYVM