Android:如何创建类似于日历应用程序的布局 - 创建事件

标签 android layout scroll scrollview footer

我正在尝试创建一个与 Android 2.x 上 native 日历应用程序的“创建事件”屏幕非常相似的表单 基本上它有一个固定的页眉、固定的页脚,中间是(我猜)一个带有不同“问题”的 ScrollView,例如“Event”、“From”、“To”、“Location”等。 ..

我尝试了几个选项,但找不到不涉及计算屏幕高度的正确布局

非常感谢任何帮助!

最佳答案

我使用 RelativeLayout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
    android:id="@+id/status_header"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:paddingTop="8px"
    android:paddingBottom="8px"
    android:gravity="center"
    android:textColor="@color/header_foreground"
    android:background="@color/header_background"
    android:text="@string/status_header"/>
<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/statuspanel"
    android:layout_above="@+id/status_footer">

把你所有的中间位放在这里,也许在 TableLayout 中

</ScrollView>
<TableLayout
    android:id="@+id/status_footer"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:paddingTop="4px"
    android:paddingLeft="2px"
    android:paddingRight="2px"
    android:stretchColumns="*"
    android:textColor="@color/footer_foreground"
    android:background="@color/footer_background">
    <TableRow>
        <Button
            android:id="@+id/status_backbutton"
            android:layout_width="0px"
            android:layout_weight="1"
            android:text="@string/status_backbutton" />
    </TableRow> 
</TableLayout>
</RelativeLayout>

您必须原谅我所有的颜色位,但您明白了。 它在 RelativeLayout 中使用 alignParent 元素,这是关键,我认为

关于Android:如何创建类似于日历应用程序的布局 - 创建事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5275655/

相关文章:

java - Android 中未显示对话框

Android Dialogfragment消除黑边(上下)

android - Monodroid - EditText 输入法不接受数字

android - 如何创建一个允许较大 child 的 View ?

android - 如何创建类似 Google Currents 的布局

javascript - 当散列更改时防止页面滚动

javascript - 当用户滚动时,补间/移动元素(如果可能的话)从/到一个类

android - 杀死导航 Controller 中的 fragment

qt - 填充父级的小部件或布局

Javafx 文本区域禁用滚动条