Android左上角的圆形边框颜色仅为dinamically

时间:2017-04-08 05:53:24

标签: android gridview layout rounded-corners border-layout

我需要动态设置一个GridView项目,我使用的是LinearLayout,背景可绘制应用圆角但是我不能指出只设置左上边框颜色,就像这张图片.... Example



<img src="https://i.stack.imgur.com/R8lyH.png"/>
&#13;
&#13;
&#13;

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/gridview_item"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/btn_rounded_white"
        android:orientation="vertical">

        <TextView
            android:id="@+id/gridview_text"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:clickable="true"
            android:text="@string/app_name"
            android:textSize="@dimen/gridview_text"
            android:textStyle="bold"
            android:layout_gravity="center"
            android:gravity="center">

        </TextView>

    </LinearLayout>


<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >
    <solid android:color="@color/griditem_cat" />
    <padding android:left="5dp"
        android:top="5dp"
        android:right="5dp"
        android:bottom="5dp"/>
    <corners android:bottomRightRadius="7dp"
        android:bottomLeftRadius="7dp"
        android:topLeftRadius="7dp"
        android:topRightRadius="7dp"/>
</shape>

1 个答案:

答案 0 :(得分:0)

<强> grid_item.xml

setItem(key: string, data: string): void;

<强> CategoryAdapter

<RelativeLayout 
android:id="@+id/gridview_item" 
android:layout_width="match_parent" 
android:layout_height="match_parent">
     <PinnedGridItemView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"/>
    <TextView android:id="@+id/gridview_text">
     </TextView>
</RelativeLayout>

Result image