绘制半径为边界的ImageView或TextView的在Android的一个角落

问题描述:

我需要绘制边框到的ImageView或在我的应用程序一个TextView,但我需要绘制它只是在一个角落里,喜欢的形象。

I need to draw a border to an imageview or a textview in my app, but I need to draw it only in one corner, like the image.

我做一个形状,但我得到了所有4个方面边框:

I do a shape but i get border in all 4 sides:

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <stroke android:width="1px" android:color="#FF000000" />
    <solid android:color="#ffffffff"/>  
    <padding android:left="1px" android:top="1px"
        android:right="0px" android:bottom="0px" />
    <corners android:topLeftRadius="8px" /> 
</shape> 

我怎么能这样做使它象的形象?

How can I to do make it like in the image?

谢谢,马蒂亚

使用此code将解决这个问题:

Use this code will solve it :

<?xml version="1.0" encoding="utf-8" ?> 
 <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  <item>
   <shape android:shape="rectangle">
    <solid android:color="#FF0000" /> 
     <corners android:topLeftRadius="15dp" /> 
    </shape>
 </item>
<item android:left="10dp" android:top="10dp">
  <shape android:shape="rectangle">
   <solid android:color="#000000" /> 
    <corners android:topLeftRadius="15dp" /> 
  </shape>
 </item>
</layer-list>

你必须做出的(布局XML)也调整为:

you have to make adjustment in the ( layout Xml ) also as:

的android:layout_width

android:layout_width

安卓layout_height

android:layout_height

安卓paddingTop

android:paddingTop

机器人:paddingLeft

android:paddingLeft

这是输出:

希望这有助于。