Android studio android studio中的渐变使用
我是安卓工作室的新成员。 只是阅读和学习有关梯度的用法。 浮动按钮是否可以使用渐变色填充整个形状?Android studio android studio中的渐变使用,android-studio,gradient,floating-action-button,textstyle,Android Studio,Gradient,Floating Action Button,Textstyle,我是安卓工作室的新成员。 只是阅读和学习有关梯度的用法。 浮动按钮是否可以使用渐变色填充整个形状? 另外,是否可以使用渐变颜色创建文本视图样式?当然可以创建background.xml可绘制文件夹并编写以下代码 <?xml version="1.0" encoding="utf-8"?> <shape> <gradient android:startColor="@color/colorAccent" and
另外,是否可以使用渐变颜色创建文本视图样式?当然可以创建background.xml可绘制文件夹并编写以下代码
<?xml version="1.0" encoding="utf-8"?>
<shape>
<gradient android:startColor="@color/colorAccent"
android:centerColor="@color/colorAccent"
android:endColor="@color/black"
android:angle="90"/>
<corners android:radius="10dp"></corners>
</shape>
当然,创建一个background.xml可绘制文件夹,并在下面编写代码
<?xml version="1.0" encoding="utf-8"?>
<shape>
<gradient android:startColor="@color/colorAccent"
android:centerColor="@color/colorAccent"
android:endColor="@color/black"
android:angle="90"/>
<corners android:radius="10dp"></corners>
</shape>
谢谢你的回答。但是是否可以只使用颜色重音,或者可以指示其他颜色? 在我的代码中,我试图使用颜色,并期待它覆盖所有浮动按钮的颜色,但我只有它像正方形在中间。 我想要实现的是在渐变背景上浮动按钮(无论是带正方的还是箭头的,喜欢前后移动)
我用背景色描述如下:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<gradient
android:angle="270"
android:startColor="#A70797"
android:endColor="#0723B5"
/>
</shape>
Then from floating action buttons, I selected the icon ic_menu_add
Actual floating action button is described like this
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_1"
style="@style/Myfbutton"
android:focusable="true"
app:fabSize="mini"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="@drawable/fback" />
For style I have
<style name="Myfbutton">Myfbutton
<item name="android:shape">oval</item>item>
<item name="android:layout_width">42dp</item>
<item name="android:layout_height">42dp</item>
<item name="android:clickable">true</item>
<item name="android:layout_margin">16sp</item>
</style>
然后从浮动动作按钮中,我选择了图标ic\u菜单\u添加
实际浮动操作按钮的描述如下
就我的风格而言
我的纽扣
椭圆形>
42dp
42dp
真的
16便士
我做错了什么?谢谢你的回答。但是是否可以只使用颜色重音,或者可以指示其他颜色? 在我的代码中,我试图使用颜色,并期待它覆盖所有浮动按钮的颜色,但我只有它像正方形在中间。 我想要实现的是在渐变背景上浮动按钮(无论是带正方的还是箭头的,喜欢前后移动)
我用背景色描述如下:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<gradient
android:angle="270"
android:startColor="#A70797"
android:endColor="#0723B5"
/>
</shape>
Then from floating action buttons, I selected the icon ic_menu_add
Actual floating action button is described like this
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_1"
style="@style/Myfbutton"
android:focusable="true"
app:fabSize="mini"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="@drawable/fback" />
For style I have
<style name="Myfbutton">Myfbutton
<item name="android:shape">oval</item>item>
<item name="android:layout_width">42dp</item>
<item name="android:layout_height">42dp</item>
<item name="android:clickable">true</item>
<item name="android:layout_margin">16sp</item>
</style>
然后从浮动动作按钮中,我选择了图标ic\u菜单\u添加
实际浮动操作按钮的描述如下
就我的风格而言
我的纽扣
椭圆形>
42dp
42dp
真的
16便士
我做错了什么?是的,你可以在任何地方应用渐变。那么,你想要哪种类型的渐变,在哪里呢?我想要的一个地方作为浮动动作按钮的背景色,根据下面的答案,复制了我的代码。你知道你想要在FAB中使用哪种类型的渐变吗。基本上,我想要一个渐变色的按钮(要么像按钮里面有加号,要么像箭头一样来回移动),我用背景色描述如下:然后从浮动动作按钮,我选择了图标ic_菜单_添加实际浮动动作按钮,描述如下是的,你可以在任何地方应用渐变。那么,你想要哪种类型的渐变,在哪里呢?我想要的一个地方作为浮动动作按钮的背景色,根据下面的答案,复制了我的代码。你知道你想要在FAB中使用哪种类型的渐变吗。基本上,我想要一个渐变色的按钮(要么像按钮里面有加号,要么像箭头一样来回移动),我用背景色描述如下:然后从浮动动作按钮,我选择了图标ic_菜单_添加实际浮动操作按钮,描述如下可能这是您的可能这是您的