導航:首頁 > 操作系統 > 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字體大小相關的資料

熱點內容
java函數return 瀏覽:25
鄭州app積分商城哪裡好 瀏覽:610
7za命令解壓zip 瀏覽:906
硬碟加密無法進入系統 瀏覽:560
四葉花演算法 瀏覽:741
寶寶濾鏡app哪裡下載 瀏覽:1002
java保護代碼 瀏覽:806
游戲海外伺服器什麼意思 瀏覽:568
快手網紅程序員排名 瀏覽:99
首先會通過什麼尋找伺服器的ip地址 瀏覽:199
網頁代碼加密解碼 瀏覽:285
wyks1ms文件夾 瀏覽:93
什麼app可以看柯南高清 瀏覽:425
加密的盤文件恢復 瀏覽:22
絕對路徑能查找隱藏文件夾嗎 瀏覽:568
做抖音相冊用什麼圖片app 瀏覽:726
pc怎麼打開sftp伺服器 瀏覽:998
中長跑用什麼app 瀏覽:943
hlddz是什麼文件夾怎麼換盤 瀏覽:458
oppo主題編譯器下載 瀏覽:807