android xml左边,Android XML – 如何将项目对齐到最左侧,中间和最右侧
您需要使用weight屬性.可以把它想象成讓android知道它應該給每個項目的寬度百分比.
你需要為所有3個項目設置寬度為0dip并添加權重屬性
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"
android:layout_width="0dip"
android:layout_weight="2" >
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Place"
android:layout_width="0dip"
android:layout_weight="1" >
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save"
android:layout_width="0dip"
android:layout_weight="2" >
玩重量值,你會明白它是如何工作的:)
在此之后,您可以使用gravity屬性將文本移動到中心/左側或右側.
總結
以上是生活随笔為你收集整理的android xml左边,Android XML – 如何将项目对齐到最左侧,中间和最右侧的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 工商银行如何开通短信提醒
- 下一篇: 趣挨踢 | 阿里员工吐槽:我在阿里工作五