導航:首頁 > 操作系統 > androidbutton字體大小

androidbutton字體大小

發布時間:2022-10-23 09:08:32

A. android中,如何在點擊button按鈕時,將button按鈕上的文字變小一點

button.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
button.setTextSize(12);
}
});

B. 如何通過代碼設置Button title的字體大小

代碼如下:

btnOpenAppURL.titleLabel.font=[UIFontsystemFontOfSize:12];

代碼中的12可以根據需要自己調節

UIFontsystemFontOfSize:[UIFontsmallSystemFontSize];//系統小字體

UIFont 擴展:

UIFontsystemFontOfSize:[UIFontlabelFontSize];//系統標簽字體
UIFontboldSystemFontOfSize:20;//加粗字體
UIFontitalicSystemFontOfSize:20;//斜體

C. 如何設置button字體 android

使用方法

第一種是在listview中配置android:listSelector=」@drawable/list_item_bg」

第二種是在listview的item中添加屬性android:background=」@drawable/list_item_bg」

第三種是java代碼中使用:

Drawable drawable = getResources().getDrawable(R.drawable.list_item_bg);
listview.setSelector(drawable);

註:列表有時候為黑的情況,需要加上下面的代碼使其透明:

android:cacheColorHint="@android:color/transparent"

使用selector設置字體顏色

drawable/button_font.xml
<?xmlversion="1.0"encoding="utf-8"?>
<selectorxmlns:android="http://schemas.android.com/apk/res/android">
<itemandroid:state_selected="true"android:color="#FF0000"/>
<itemandroid:state_focused="true"android:color="#00FF00"/>
<itemandroid:state_pressed="true"android:color="#0000FF"/>
<itemandroid:color="#000000"/>
</selector>

使用方法

android:textColor="@drawable/button_color"

更復雜的效果

還可以實現更復雜的效果,例如漸變等等。drawable/button_color.xml

<?xmlversion="1.0"encoding="utf-8"?>
<selectorxmlns:android="http://schemas.android.com/apk/res/android">
<itemandroid:state_pressed="true">
<!--定義當button處於pressed狀態時的形態。-->
<shape>
<gradientandroid:startColor="#8600ff"/>
<strokeandroid:width="2dp"
android:color="#000000"/>
<cornersandroid:radius="5dp"/>
<paddingandroid:left="10dp"
android:top="10dp"
android:bottom="10dp"
android:right="10dp"/>
</shape>
</item>
<itemandroid:state_focused="true">
<!--定義當button獲得focus時的形態-->
<shape>
<gradientandroid:startColor="#eac100"/>
<strokeandroid:width="2dp"
android:color="#333333"
color="#ffffff"/>
<cornersandroid:radius="8dp"/>
<paddingandroid:left="10dp"
android:top="10dp"
android:bottom="10dp"
android:right="10dp"/>
</shape>
</item>
</selector>

使用方法

android:background="@drawable/button_color"
android:focusable="true"

D. 問一個 android button 的問題 字體和 button 顯示比例的問題

android:paddingTop="0dp"
android:paddingBottom="0dp"
親試

E. android 的button 如何在設置背景後根據文字的多少變換大小

1、建議你用.9.png來製作背景,然後設置好
2、button的寬度設置成warp_content,給它自適應,然後文字有多少就可以自動的調整了

F. 如何設置button 大小及按鈕上字體大小

Button
在其屬性中有value這個欄位,修改裡面的字就可以按鈕的字了,也可以使用圖片代替按鈕背景。圖片多大,按鈕就多大

G. 關於BUTTON裡面字體大小,設置大了就不居中了,怎麼解決...

1.如果button的背景沒有使用.9圖片,則android:gravity="center"2.如果使用了.9圖片,修改圖片吧3.僅供參考

閱讀全文

與androidbutton字體大小相關的資料

熱點內容
伺服器未響應怎麼解決手機 瀏覽:184
程序員回到古代 瀏覽:402
軟體合並一個文件夾 瀏覽:657
設置Android程序圖標 瀏覽:365
app哪個局 瀏覽:904
源碼編輯器中怎麼保存 瀏覽:463
python背景圖片代碼 瀏覽:448
3D卡片下載哪個App 瀏覽:532
如何用伺服器登錄微信 瀏覽:841
html5移動開發pdf下載 瀏覽:525
如何查看png圖片是否加密 瀏覽:821
php遞歸例子 瀏覽:190
伺服器參數配置未響應是什麼意思 瀏覽:603
pythonchardet模塊 瀏覽:751
添加gm命令 瀏覽:662
rsa加密碼亂碼 瀏覽:758
網站伺服器需要租什麼 瀏覽:999
c語言常用排序演算法 瀏覽:824
pythonhtml文件上傳 瀏覽:525
dosat命令執行exe 瀏覽:95