简体   繁体   English

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

[英]Android: How to create a layout similar to Calendar app - create event

I'm trying to create a form very similar to the "Create event" screen of the native Calendar app on Android 2.x Basically it has a fixed header, fixed footer and the middle is (I guess) a ScrollView with different "questions" such as "Event", "From", "To", "Location" etc... 我正在尝试创建一个与Android 2.x上本机Calendar应用程序的“创建事件”屏幕非常相似的表单。基本上,它具有固定的页眉,固定的页脚,中间是(我想)带有不同“问题”的ScrollView ”,例如“事件”,“发件人”,“发件人”,“位置”等...

I've tried a few options but I can't find the right layout that doesn't involve calculating the height of the screen 我尝试了一些选项,但是找不到不涉及计算屏幕高度的正确布局

Any help would be very much appreciated! 任何帮助将不胜感激!

I use a RelativeLayout: 我使用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">

Put all your middle bits here, maybe in a TableLayout 将所有中间位放在此处,也许放在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>

You'll have to excuse all my colour bits, but you get the idea. 您必须原谅我所有的色位,但是您明白了。 It's using alignParent elements in a RelativeLayout which is key, I think 我认为这是在RelativeLayout中使用alignParent元素的,这是关键

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM