android xml左边,Android XML – 如何将项目对齐到最左侧,中间和最右侧
您需要使用weight屬性.可以把它想象成讓android知道它應(yīng)該給每個(gè)項(xiàng)目的寬度百分比.
你需要為所有3個(gè)項(xiàng)目設(shè)置寬度為0dip并添加權(quán)重屬性
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" >
玩重量值,你會(huì)明白它是如何工作的:)
在此之后,您可以使用gravity屬性將文本移動(dòng)到中心/左側(cè)或右側(cè).
總結(jié)
以上是生活随笔為你收集整理的android xml左边,Android XML – 如何将项目对齐到最左侧,中间和最右侧的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 工商银行如何开通短信提醒
- 下一篇: 接口使用jwt返回token_API接口