我是 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/