0
我是絕對的初學者,當涉及到單聲道爲Android。單聲道按鈕的造型爲Android
參照下面的截圖,默認按鈕樣式(左圖)在這裏看起來不太好。所以我想把它改成確切的矩形(右圖)而不是圓角矩形(默認的)。
對此有何想法?
需要添加任何xml文件嗎?
因爲我很新的這一點,任何幫助將不勝感激!
我是絕對的初學者,當涉及到單聲道爲Android。單聲道按鈕的造型爲Android
參照下面的截圖,默認按鈕樣式(左圖)在這裏看起來不太好。所以我想把它改成確切的矩形(右圖)而不是圓角矩形(默認的)。
對此有何想法?
需要添加任何xml文件嗎?
因爲我很新的這一點,任何幫助將不勝感激!
用途,以創造圓角按鈕背景
RES /繪製/ rounded_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- res/drawable/rounded_bg.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="@color/blue1"/>
<corners
android:bottomRightRadius="5dp"
android:bottomLeftRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp"/>
</shape>
,並使用此代碼,作爲背景的按鈕
android:background="@drawable/rounded_bg"
Thnx很多爲您的迴應。但我已經通過編程創建了按鈕。因此,而不是'android:background =「@ drawable/rounded_bg」',應該使用什麼? – GAMA 2012-03-26 05:15:15
button.setBackgroundDrawable(R.drawable.rounded_bg); – 2012-03-26 05:18:16
我知道這個stmt。但是我使用'mono for android',所以在這裏不起作用,因爲它將'R.drawable.rounded_bg'視爲整數,因此錯誤'不能從int轉換爲drawable'。 – GAMA 2012-03-26 05:28:08