Android的XML形状绘制

问题描述:

enter image description hereAndroid的XML形状绘制

我想提请上面显示图像android.please帮我

+0

尝试后,你已经完成的工作是什么,什么问题你正面临着。 – gprathour

+0

http://stackoverflow.com/questions/2459916/how-to-make-an-imageview-with-rounded-corners检查它 –

试试这个XML版图形状:

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle" > 
    <solid android:color="#ffffff" /> 
    <stroke android:color="#80000000" 
     android:width="0.5dp" 
     /> 
    <corners 
     android:bottomLeftRadius="32dp" 
     android:topLeftRadius="32dp" /> 
</shape> 

首先尽量展现你的进步或你到目前为止所尝试过的以及你卡在哪里。

其次你的问题,使用下面的代码:

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item 
     android:bottom="10dp" 
     android:top="10dp"> 

    <shape android:shape="rectangle"> 
     <solid android:color="@android:color/black" /> //change your desired color 
//use can set your desired size to make curve 
     <corners 
      android:bottomLeftRadius="10dp" 
      android:bottomRightRadius="0dp" 
      android:topLeftRadius="10dp" 
      android:topRightRadius="0dp" /> 
    </shape> 
</item> 

创建此绘制,并在XML

+0

感谢您的代码 –

使用如果你想只剩两个角弯曲。然后,只需设置bottomRightRadius & topRightRadius0dp

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <solid android:color="@color/color_Transport_Grey" /> 

    <corners 
     android:bottomLeftRadius="10dp" 
     android:bottomRightRadius="0dp" 
     android:topLeftRadius="10dp" 
     android:topRightRadius="0dp" /> 
    <padding 
     android:left="0dip" 
     android:right="0dip" /> 
</shape> 

你的形状(fab.xml):

<?xml version="1.0" encoding="utf-8"?> 
<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="@color/main_light_extreme"> 
    <item android:id="@android:id/mask"> 
     <shape android:shape="oval"> 
      <solid android:color="@color/main_light_extreme" /> 
     </shape> 
    </item> 
    <item> 
     <shape android:shape="oval"> 
      <solid android:color="@color/main_normal" /> 
     </shape> 
    </item> 
</ripple> 

您与形状背景图片(ImageButton的):

<ImageButton 
     android:id="@+id/fab" 
     android:layout_width="56dp" 
     android:layout_height="56dp" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentEnd="true" 
     android:layout_marginBottom="54dp" 
     android:layout_marginEnd="36dp" 
     android:background="@drawable/fab" 
     android:src="@android:drawable/ic_menu_camera" <!-- your need this --> 
     android:elevation="12dp" /> 

结果(注:纹波只能Android的API> = 21棒棒堂):

Simple float action button.

图片上面绘制形状:d