[英]Layout for Android. Fluid layout and a fixed layout
我要開發一個需要使用類似布局顯示數據的Android應用程序。 我需要屏幕的兩個部分:
這個怎么做? 我使用了relativelayout和linearlayout,但我還沒有找到解決方案。 你可以幫幫我嗎?
<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>
使用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>
對於一個LinearLayout
設置頂部布局到android:layout_weight="1"
(和高度為0dp
)和底部layout_height
到固定值或android:layout_height="wrap_content"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#FF0000" />
<View
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#00FF00" />
</LinearLayout>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.