android按钮固定尺寸,如何在android中保持按钮的固定宽高比
我正在改進(jìn)你的XML.我沒有測試它,但它應(yīng)該工作.建議的更改是,而不是將圖像設(shè)置為背景,將其設(shè)置為ImageButtons的src.此外,如果您堅(jiān)持使用Button,則可以使用其他布局包裝每個(gè)按鈕,并將其重力屬性設(shè)置為“center”.看一下下面的XML.
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/main_background"
android:baselineAligned="false"
android:orientation="vertical" >
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/answer_bg"
android:padding="10dip" >
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" >
android:id="@+id/b2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/img_background"
android:height="50dip"
android:text="@string/x"
android:textStyle="bold" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" >
android:id="@+id/b3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/img_background"
android:height="50dip"
android:text="@string/x"
android:textStyle="bold" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" >
android:id="@+id/b4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/img_background"
android:height="50dip"
android:text="@string/x"
android:textStyle="bold" />
隨意詢問它是否不起作用.
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的android按钮固定尺寸,如何在android中保持按钮的固定宽高比的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: app源码+php+l,android商
- 下一篇: 移动平台课程设计--日记本