導航:首頁 > 操作系統 > android半圓按鈕

android半圓按鈕

發布時間:2022-05-18 06:54:21

android 怎麼把button變成圓形

使用shape,請看下面截圖,例子來自於android學習手冊,360手機助手中下載,裡面有108個例子、源碼還有文檔。



<?xml version="1.0" encoding="utf-8"?>

<shape

xmlns:Android="http://schemas.android.com/apk/res/android"

android:shape="oval">

<!-- 填充的顏色 -->

<solid android:color="#FFFFFF"/>

<!-- 設置按鈕的四個角為弧形 -->

<!-- android:radius 弧形的半徑 -->

<corners android:radius="360dip"/>

<!-- padding: Button 裡面的文字與Button邊界的間隔 -->

<padding

android:left="10dp"

android:top="10dp"

android:right="10dp"

android:bottom="10dp"

/>

</shape>

-----Main layout文件

<?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/soft_info"

/>

<!—直接設置背景 -->

<Button

android:id="@+id/roundBtn1"

android:background="@drawable/btn_oval"

android:layout_width="50dip"

android:layout_height="50dip"

/>

<!— 調用shape自定義xml文件 -->

<Button

android:id="@+id/roundBtn"

android:text="橢圓按鈕"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:background="@drawable/main_menu_btnshape"

/>

</LinearLayout>

----acitivity文件

public class MyLifeActivity extends Activity {

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

}

}

⑵ 安卓調試中如何更改圖片按鈕的形狀,改為圓形

shape
<shape>和<selector>在Android UI設計中經常用到。比如我們要自定義一個圓角Button,點擊Button有些效果的變化,就要用到<shape>和<selector>。
可以這樣說,<shape>和<selector>在美化控制項中的作用是至關重要。

在看這篇文章之前,可以看下這個小例子:鏤空按鈕的實現

1.Shape

簡介

作用:XML中定義的幾何形狀

位置:res/drawable/文件的名稱.xml

使用的方法:

java代碼中:R.drawable.文件的名稱

XML中:Android:background="@drawable/文件的名稱"

屬性:

<shape> Android:shape=["rectangle" | "oval" | "line" | "ring"]

其中rectagle矩形,oval橢圓,line水平直線,ring環形

<shape>中子節點的常用屬性:

<gradient> 漸變

Android:startColor

起始顏色

Android:endColor

結束顏色

Android:angle

漸變角度,0從左到右,90表示從下到上,數值為45的整數倍,默認為0;

Android:type

漸變的樣式 liner線性漸變 radial環形漸變 sweep

<solid > 填充

Android:color

填充的顏色

<stroke >描邊

Android:width

描邊的寬度

Android:color

描邊的顏色

Android:dashWidth

表示'-'橫線的寬度

Android:dashGap

表示'-'橫線之間的距離

<corners >圓角

Android:radius

圓角的半徑 值越大角越圓

Android:topRightRadius

右上圓角半徑

Android:bottomLeftRadius

右下圓角角半徑

Android:topLeftRadius

左上圓角半徑

Android:bottomRightRadius

左下圓角半徑

⑶ Android中用什麼控制項可以做出類似於實況足球里那樣的圓形方向控制按鈕

一般都是自定義View,也可以嘗試用兩個View疊加起來,小圓點實現OnTouch事件

⑷ android中,如何做圓形的button按鈕

自己繪制圓形的圖片,然後在button布局裡面用BackgroundDrawable設置為button背景。android中是不帶圓形的button的

⑸ android 怎樣用shape畫一個倆邊半圓的按鈕背景

用shape畫一個倆邊半圓的按鈕,可以用圖形畫。
Circle方法用來畫圓、橢圓、圓弧和餅分圖。
畫圓,Visual Basic需要給出這個圓的圓心位置和它的半徑:「對象. Circle Step (x, y),半徑,顏色」。
如果不指定對象,指定的就是當前的窗體。
用繪圖區的標尺屬性,可以使圓心置於繪圖區域的中心處。

⑹ 求教,android中Button能不能變成圓形

可以用兩張圖片,一張普通狀態,一張焦點狀態,然後自己做個selector。設置button的background為這個selector

⑺ 華為手機屏幕上有個圓圈

1、屏幕上的圓圈是懸浮按鈕功能。

2、點擊將展開懸浮按鈕,會顯示常用功能,包括返回、主屏幕、鎖屏和一鍵優化等功能。

3、隱藏方法:

  1. 在手機桌面中點擊打開「設置」選項,打開「設置」後,進入到「常用設置」界面。

    (7)android半圓按鈕擴展閱讀:

    1、截止2015年,華為的產品和服務遍及170多個國家,服務於全球1/3人口,在中國、俄羅斯、德國、瑞典、印度及美國等地設立了16個研發中心。消費者業務是華為三大業務之一,產品全面覆蓋手機、移動寬頻和家庭終端。

    2、華為消費者業務將堅持精品戰略,目前產品系列有Mate系列的極致科技、P系列的極致時尚、G系列的極致以及暢享系列。

    3、2015年全年,華為消費者業務發布了P8、P8max、P8青春版、Mate S、G7 Plus、麥芒4、Mate 8、等多款手機產品以及HUAWEI WATCH等可穿戴設備。

    ⑻ android開發中,點擊一個按鈕,周圍出現三個按鈕

    先把3個按鈕隱藏,點擊了按鈕A,就顯示3個按鈕

    我試了下,可以的

    test.xml:

    <?xmlversion="1.0"encoding="utf-8"?>
    <RelativeLayoutxmlns:android="
    android:id="@+id/relativeLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <Button
    android:id="@+id/btA"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"
    android:text="按鈕A"/>
    <Button
    android:id="@+id/btB"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_toLeftOf="@id/btA"
    android:text="按鈕B"/>
    <Button
    android:id="@+id/btD"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_toRightOf="@id/btA"
    android:text="按鈕D"/>
    <Button
    android:id="@+id/btC"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/btA"
    android:layout_toLeftOf="@+id/btD"
    android:text="按鈕C"/>
    </RelativeLayout>

    TestActivity:
    packagecom.example.androidtest;
    importandroid.app.Activity;
    importandroid.os.Bundle;
    importandroid.view.View;
    importandroid.view.View.OnClickListener;
    importandroid.widget.Button;
    importandroid.widget.Toast;
    {
    privateButtonbtA;
    privateButtonbtB;
    privateButtonbtC;
    privateButtonbtD;
    privatebooleanisVisible=true;
    @Override
    publicvoidonCreate(BundlesavedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.test);
    btA=(Button)findViewById(R.id.btA);
    btB=(Button)findViewById(R.id.btB);
    btC=(Button)findViewById(R.id.btC);
    btD=(Button)findViewById(R.id.btD);
    btB.setVisibility(View.INVISIBLE);
    btC.setVisibility(View.INVISIBLE);
    btD.setVisibility(View.INVISIBLE);
    btA.setOnClickListener(newOnClickListener(){
    @Override
    publicvoidonClick(Viewv){
    if(isVisible){
    btB.setVisibility(View.VISIBLE);
    btC.setVisibility(View.VISIBLE);
    btD.setVisibility(View.VISIBLE);
    isVisible=false;
    }else{
    btB.setVisibility(View.INVISIBLE);
    btC.setVisibility(View.INVISIBLE);
    btD.setVisibility(View.INVISIBLE);
    isVisible=true;
    }
    }
    });
    }
    }

    ⑼ 安卓手機有沒有插件做出類似蘋果的圓形按鈕

    Easy touch 軟體

    ⑽ android,,圖片按鈕,如何把這個按鈕的圓圈之外設為透明,圓圈裡的正常顯示啊

    你把這張圖片導進Ps軟體里,把圓形以外的區域刪除掉,保存為png的圖片,然後你再通過復制粘貼,放到drawable文件夾里,使用ImageButton來載入圖片,在class里設置ImageButton的單擊事件就可以了,

    我看到你的圖片是Jpeg的圖片,如果放入這樣的圖片,周圍的白色區域是去掉不了的(除非用動態代碼控制,但是那樣比較麻煩)

    記得用Png格式的圖片覆蓋到ImageButton控制項上

閱讀全文

與android半圓按鈕相關的資料

熱點內容
解壓小熊手機殼 瀏覽:342
成都市區建成面積演算法 瀏覽:658
智能家居單片機 瀏覽:95
買男裝用什麼app好 瀏覽:853
文件夾合並了怎麼拆開 瀏覽:257
波段副圖源碼無未來函數 瀏覽:86
livecn伺服器地址 瀏覽:257
程序員這個工作真的很吃香嗎 瀏覽:844
程序員和數學分析師待遇 瀏覽:678
壓縮氣彈簧怎麼拆 瀏覽:321
華為公有雲伺服器添加虛擬ip 瀏覽:209
程序員和運營哪個累 瀏覽:24
抖音安卓信息提示音怎麼設置 瀏覽:454
光速虛擬機的共享文件夾 瀏覽:248
程序員培訓機構發的朋友圈真實性 瀏覽:744
天乾地支簡單演算法 瀏覽:299
下載個壓縮文件 瀏覽:300
普通人電腦關機vs程序員關機 瀏覽:630
米酷建站源碼 瀏覽:115
氫氣app怎麼搜搭配 瀏覽:619