java 制作圆形按钮

编程入门 行业动态 更新时间:2024-10-09 03:30:25

java 制作<a href=https://www.elefans.com/category/jswz/34/1769013.html style=圆形按钮"/>

java 制作圆形按钮

回答(14)

2 years ago

在drawable文件夹中创建名为 roundedbutton.xml 的xml文件

android:shape="rectangle">

android:bottomLeftRadius="8dp"

android:topRightRadius="8dp"

android:topLeftRadius="8dp"/>

最后将其设置为 Button 的背景为 android:background = "@drawable/roundedbutton"

如果你想让它完全圆润,改变半径并找到适合你的东西 .

2 years ago

如果使用Android Studio,您可以使用:

android:shape="ring">

这对我来说很好,希望这有助于某人 .

2 years ago

创建一个drawable / button_states.xml文件,其中包含:

android:width="2dip"

android:color="#03ae3c" />

android:bottom="4dp"

android:left="4dp"

android:right="4dp"

android:top="4dp" />

android:width="2dip"

android:color="#03ae3c" />

android:bottom="4dp"

android:left="4dp"

android:right="4dp"

android:top="4dp" />

在任何布局文件的按钮标记中使用它

android:layout_width="220dp"

android:layout_height="220dp"

android:background="@drawable/button_states"

android:text="@string/btn_scan_qr"

android:id="@+id/btn_scan_qr"

android:textSize="15dp"

/>

2 years ago

Markushi's android circlebutton:

(这个库已被弃用,并没有进行新的开发 . 请考虑使用FAB . )

2 years ago

使用的形状为椭圆形 . 这使按钮呈椭圆形

android:height="1.0dip"

android:width="1.0dip"

android:color="#ffee82ee" />

android:bottomLeftRadius="12.0dip"

android:bottomRightRadius="12.0dip"

android:radius="12.0dip"

android:topLeftRadius="12.0dip"

android:topRightRadius="12.0dip" />

2 years ago

android:bottomLeftRadius="180dip"

android:topRightRadius="180dip"

android:topLeftRadius="180dip"/>

并将其添加到按钮代码中

android:layout_width="50dp"

android:layout_height="50dp"

2 years ago

您可以使用圆形背景图像制作 ImageButton .

2 years ago

使用 ImageButton 代替Button ....

并使用 transparent 背景制作圆形图像

2 years ago

对于圆形按钮创建一个形状:

android:width="8dp"

android:color="#FFFFFF" />

android:bottomLeftRadius="45dp"

android:bottomRightRadius="45dp"

android:topLeftRadius="45dp"

android:topRightRadius="45dp" />

用它作为按钮的背景link

2 years ago

android:shape="oval">

android:color="#ffffff"

/>

在您的XML可绘制资源上设置它,并使用您的drawable作为背景简单使用带有圆形图像的图像按钮 .

2 years ago

它是

android.R.drawable.expander_ic_minimized

看看内置的android drawables:

2 years ago

你可以使用谷歌的FloatingActionButton

XML:

android:id="@+id/fab"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:src="@android:drawable/ic_dialog_email" />

Java的:

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

FloatingActionButton bold = (FloatingActionButton) findViewById(R.id.fab);

bold.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

// Do Stuff

}

});

}

摇篮:

compile 'com.android.support:design:23.4.0'

更多推荐

java 制作圆形按钮

本文发布于:2024-02-28 07:42:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1768746.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:圆形   按钮   java

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!