使用即时贴视图时无法获得精确的圆形 [英] Unable to get exact circle shape when using card view

查看:106
本文介绍了使用即时贴视图时无法获得精确的圆形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android材质设计中将卡片视图用于浮动操作按钮.我正在使用以下代码来获取圆圈

I'm using card view for floating action button in android material design. I'm using following code for get the circle

<android.support.v7.widget.CardView
    android:id="@+id/fab"
    android:layout_width="38dp"
    android:layout_height="38dp"
    android:layout_marginBottom="10dp"
    android:layout_marginRight="10dp"
    card_view:background="@color/blue"
    card_view:cardCornerRadius="19dp"
    card_view:cardPreventCornerOverlap = "false"
    card_view:cardElevation="6dp" >
</android.support.v7.widget.CardView>

我将拐角半径设置为宽度的一半.但仍然无法获得圆形形状.

I have set corner radius as half of width. but still I can't get the circle shape.

推荐答案

我已经解决了这个问题.现在,android为材质设计提供了设计库,该库具有 FloatingActionButton.无需为浮动操作按钮自定义卡片视图.

I have solved the problem. Now android providing design library for material design, which has the FloatingActionButton. No need of customizing card view for floating action button.

<android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"  />

在gradle依赖项中添加设计库

Add design library in gradle dependencies

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

有关更多详细信息,请参见此链接

For more detail refer this link

这篇关于使用即时贴视图时无法获得精确的圆形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆