布局Android系统。流动布局和固定布局 [英] Layout for Android. Fluid layout and a fixed layout
本文介绍了布局Android系统。流动布局和固定布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经开发一个Android应用程序,需要使用一个类似的布局显示数据。
我需要屏幕两部分组成:
- 用流体高度的布局对设备的分辨率而异
- 二布局,显示在一个固定尺寸 内容
如何做到这一点?我用的RelativeLayout和的LinearLayout,但我还没有找到一个解决方案。
你能帮助我吗?
解决方案
<的RelativeLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent> <的LinearLayout
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_above =@ + ID / fixedlayout
机器人:layout_alignParentTop =真
机器人:layout_centerHorizontal =真
机器人:方向=垂直
机器人:ID =@ + ID / fluidlayout>
< / LinearLayout中> <的LinearLayout
机器人:layout_width =match_parent
机器人:layout_height =200dp
机器人:layout_alignParentBottom =真
机器人:layout_alignParentLeft =真
机器人:layout_alignParentRight =真
机器人:方向=垂直
机器人:ID =@ + ID / fixedlayout>
< / LinearLayout中>< / RelativeLayout的>
使用更高效的解决方案的LinearLayout
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent> <的LinearLayout
机器人:layout_width =match_parent
机器人:layout_height =0dp
机器人:layout_weight =1>
< / LinearLayout中> <的LinearLayout
机器人:layout_width =match_parent
机器人:layout_height =200dp>
< / LinearLayout中>< / LinearLayout中>
I've to develop an Android application that needs to show data using a similar layout. I need two parts of screen:
- A layout with a fluid height that vary on resolution of device
- Second layout that show content in a fixed size
How to do this? I've used relativelayout and linearlayout but I haven't found a solution. Could you help me?
解决方案
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/fixedlayout"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:orientation="vertical"
android:id="@+id/fluidlayout" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:orientation="vertical"
android:id="@+id/fixedlayout" >
</LinearLayout>
</RelativeLayout>
More efficient solution using LinearLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp" >
</LinearLayout>
</LinearLayout>
这篇关于布局Android系统。流动布局和固定布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文