當前位置:編程學習大全網 - 電腦編程 - android編程 能不能在xml中設置控件寬度為父窗口的壹半

android編程 能不能在xml中設置控件寬度為父窗口的壹半

使用 android:layout_weight 屬性。例子:

<LinearLayout

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:weightSum="1.0">

<Button

android:text="left"

android:layout_width="0dp"

android:layout_height="wrap_content"

android:layout_weight=".50"/>

<Button

android:text="right"

android:layout_width="0dp"

android:layout_height="wrap_content"

android:layout_weight=".50"/>

</LinearLayout>

  • 上一篇:隨機產生10個屬於[0—100]的自然數,並保存在數組a中,然後在窗體上顯示,10個數的平均值
  • 下一篇:java是否定義了自己的包域名?
  • copyright 2024編程學習大全網