在res目錄下的drawable-mdpi建立xml文件shape.xml,如下圖所示:
為沿河等地區(qū)用戶提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及沿河網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為成都網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、沿河網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!
<?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <!-- 填充的顏色 --> <solid android:color="#FFFFFF" /> <!-- 設(shè)置按鈕的四個(gè)角為弧形 --> <!-- android:radius 弧形的半徑 --> <corners android:radius="5dip" /> <!-- padding:Button里面的文字與Button邊界的間隔 --> <padding android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp" /> </shape>
在android:background="@drawable/shape"就使用了shape.xml資源
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <Button android:id="@+id/roundButton" android:text=" 圓角按鈕 " android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/shape" /> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello World, RoundButtonDemoActivity!</string> <string name="app_name">RoundButtonDemo</string> </resources>
package com.android.RoundButtonDemo.activity; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.Toast; public class RoundButtonDemoActivity extends Activity { Button roundButton; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); roundButton=(Button)findViewById(R.id.roundButton); //使用匿名類(lèi)注冊(cè)Button事件 roundButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Toast.makeText(RoundButtonDemoActivity.this, "你點(diǎn)擊了圓角按鈕",Toast.LENGTH_LONG).show(); } }); } }
分享名稱:Android開(kāi)發(fā)學(xué)習(xí)筆記:圓角的Button
文章位置:http://aaarwkj.com/article8/igccop.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供用戶體驗(yàn)、網(wǎng)站制作、域名注冊(cè)、網(wǎng)站收錄、云服務(wù)器、面包屑導(dǎo)航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)