安卓/布局:如何创建一个标题,内容布局 [英] Android / layout: how to create a header-content layout
问题描述
我如何去创造以下布局的Android?
How do I go about creating the following layout in Android?
我想要头,也就是说保持相同的时刻的标头。应该改变的唯一的事情是标题下面的区域。
I want a "header", that is, a header that stays the same at all times. The only thing that should change is the area below the header.
你可以把它作为一个网页,其中的内容区是所有发生的事情=)
Think of it as a webpage, where the content-area is where its all happening =)
+--------------------+
| H E A D E R |
+--------------------+
| |
| |
| |
| C O N T E N T |
| |
| |
| |
+--------------------+
当然,它很容易创建LinearLayot,在顶部添加一个视图,然后在下面的另一种观点 - 田田!但是我以后就是你如何设置或设计的项目,所以它很容易,只是在内容改变什么。
Sure, its easy enough to create a LinearLayot, add a View on the top and then another view below that - tada! But what Im after is how you "set up" or design the project so its easy to just change whats in the Content.
我的真的的希望就是能刷卡(见<一href="http://stackoverflow.com/questions/1959106/android-how-to-create-different-screens-and-nav-between-them-using-touch-and-d">here)该地区,然后就滚在新视图/的事,在内容方面,但保持了相同的标题。
What I really would like is to be able to "swipe" (see here) the area and then just "roll in" a new View/thing in the Content-area, but keep the same header.
我真的很想念是layoyt-例子COM prehensive库...
What I really miss is a comprehensive library of layoyt-examples...
关于
推荐答案
您可以创建你的头一个布局文件。在为每个内容活动的布局的顶部,包括像布局文件:
You can create a layout file for your header. At the top of the layout for each content activity, include the layout file like:
<include android:id="@+id/header"
layout="@layout/my_header"
android:layout_height="wrap_content"
android:layout_width="fill_parent"/>
究竟如何你的头在内容布局的顶部呆会根据您的布局的休息而有所不同。你可以使用的LinearLayout与方向=垂直,或align_parentTop您的包括语句相对布局=真。
How exactly you get the header to stay at the top of the content's layout will vary based on the rest of your layout. You could use a LinearLayout with orientation="vertical", or a relative layout with align_parentTop="true" on your include statement.
这机器人文档有基本布局类型的一个很好的总结。
This android documentation has a good summary of basic layout types.
这篇关于安卓/布局:如何创建一个标题,内容布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!