android - 在 android 中使用什么布局来生成数据输入表单

标签 android android-layout

使用 tp 在 android 中生成像这样的数据输入表单的最佳布局是什么: entry form

我应该使用垂直线性布局,每个项目都使用水平布局吗?或相对布局。我不能使用表格布局,因为每个文本条目可能都有自己的宽度。

谢谢

最佳答案

作为主布局,您可以使用垂直线性布局,对于每一行,水平线性布局,将宽度设置为 fill_parent。 对于前 4 行(数据表单容器),在设置宽度时,宽度使用“0 dip”,并根据需要为 layout_weight 设置一个比例,为保持对齐,下 3 行保持相同的值。不要忘记为第一列设置正确的引力

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" 
    android:paddingLeft="50dip"
    android:paddingRight="50dip"> 

<TextView 
    android:layout_width="0dip"
    android:layout_height="wrap_content"
    android:layout_weight="0.3"
    android:text="label"
    android:gravity="right"/>

<EditText 
    android:layout_width="0dip"
    android:layout_height="wrap_content"
    android:layout_weight="0.7"
    android:hint="value"
    android:layout_marginLeft="15dip"/>

</LinearLayout>


</LinearLayout>

这样做,最后一行每列的比例为 0.5。

想想,这对你有帮助...

关于android - 在 android 中使用什么布局来生成数据输入表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9517562/

相关文章:

android - 从 Parse 向我的应用程序发送推送时未收到 deviceToken

android - 如何在android中的操作栏上添加多个图标?

android - MediaCodec KEY_FRAME_RATE 似乎被忽略了

java - 在第二个 Intent 中刷新数组列表

android - 如何使用 onItemSelectedListener 改变 View 的颜色

Android TextView - 每 20 个字符后添加一个新行

java - Android:网络浏览器中的 GPS

java - 输入无法解析: Using Scanner class and Array

android - 自定义 RatingBar 未显示超过 1 星

Android水平布局,右侧动态扩展TextView