android - 使用安卓布局

标签 android android-layout android-linearlayout

我是 android 的新手,定位元素与 web 的定位元素有很大不同。
所以我想做的是:

Login: ______  
Password: _____  

我能得到的是,通过将 linearLayout 设置为垂直方向:

Login:  
__  
Password:  
__

或者这个,水平方向:

Login:_____Password:_____  

我如何混合它并实现我需要的?

当前代码:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout 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="wrap_content"
        android:orientation="horizontal"
        android:id="@+id/mainActivity"
        tools:context=".MainActivity">

        <TextView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:text="Login:"
        android:textSize="14pt"/>

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

        <TextView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:text="Senha:"
        android:textSize="14pt"/>  

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


    </LinearLayout>

最佳答案

嵌套你的线性布局。有一个垂直的顶级线性布局,内部有 2 个水平线性布局,每个布局输出一行。

关于android - 使用安卓布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50919273/

相关文章:

android - 如何在 Android 上自定义按钮(有两个文本字段)

java - 缓存已存储在文件系统上的解码位图

Android:水平列表换行符与 trello 之类的标签

android - 我可以获取 Android 的 Google map 应用程序的源代码吗?

android - 在一行中将图像与文本基线对齐

android - 包括一个背景可绘制的 foobars 我在 Android 中的布局。想法为什么?

android - 在 Android 中扩展 LinearLayout 时如何将其他参数传递给构造函数?

Android Studio 项目需要旧版本的 Gradle

Java:将数组数组的字符串表示形式转换为对象列表

android - 如何在 Android Javadoc 中引用 XML 文件?