實現控制項始終在視窗底部

2022-09-11 02:24:11 字數 2593 閱讀 1082

實現效果如下:

實現步驟:

1、使用 lin

earl

ayou

tli

near

layo

ut布局2、把想要在底部的那個控制項的and

roid

:lay

out_

weig

ht

androi

d:la

yout

_wei

ght 設為 1,這個屬性被設為非0值時,檢視將會被拉伸,可以分配到額外的空間。(對於weight的用法參考這篇部落格)and

roid

:gra

vity

androi

d:gr

**it

y設為 bot

tombo

ttom

,底部對齊

a nd

roid

:lay

out_

heig

ht

androi

d:la

yout

_hei

ght 設為 0dp(設為match_parent、wrap_parent也行,這個不重要)

**實現:

<?xml version="1.0" encoding="utf-8"?>

xmlns:android

=""=""

xmlns:tools

=""android:layout_width

="match_parent"

android:layout_height

="match_parent"

android:orientation

="vertical"

tools:context

=".mainactivity"

>

android:layout_width

="match_parent"

android:layout_height

="wrap_content"

android:id

="@+id/listview"

/>

android:layout_width

="match_parent"

android:layout_height

="0dp"

android:layout_weight

="1"

android:gr**ity

="bottom"

android:orientation

="horizontal"

>

android:layout_width

="60dp"

android:layout_height

="60dp"

android:src

="@drawable/cat2"

android:id

="@+id/addimageid"

/>

android:layout_marginleft

="10dp"

android:layout_width

="wrap_content"

android:layout_height

="wrap_content"

android:text

="名字"

/>

android:layout_width

="40dp"

android:layout_height

="wrap_content"

android:layout_weight

="1"

android:id

="@+id/addname"

/>

android:layout_marginleft

="10dp"

android:layout_width

="wrap_content"

android:layout_height

="wrap_content"

android:text

="描述"

/>

android:layout_width

="40dp"

android:layout_height

="wrap_content"

android:layout_weight

="1"

android:id

="@+id/adddesc"

/>

android:layout_marginleft

="20dp"

android:layout_width

="wrap_content"

android:layout_height

="wrap_content"

android:text

="新增"

android:id

="@+id/addbtn"

/>

linearlayout

>

linearlayout

>

C 子視窗呼叫父視窗控制項的委託實現

有時子窗體的操作需要實時呼叫父窗體中的控制項操作,比如在父窗體的文字框中顯示子窗體中的輸出 主窗體 csharp view plain copy mainform.cs public partial class mainform form private void button1 click obj...

C 子視窗呼叫父視窗控制項的委託實現

有時子窗體的操作需要實時呼叫父窗體中的控制項操作,比如在父窗體的文字框中顯示子窗體中的輸出 主窗體 csharp view plain copy mainform.cs public partial class mainform form private void button1 click obj...

子視窗(控制項)對齊類的實現(C 實現)

標頭檔案 檔名稱 alignability.h 功能說明 使你的視窗具有子視窗對齊能力。用法說明 1,在你的父視窗類中定義乙個對齊類物件 當然也可放在類外 如 calignability m align 2,為對齊類物件設定父視窗類的控制代碼。如 m align.setparenthwnd gets...