Android圆角边框颜色左上角仅动态

标签 android gridview layout rounded-corners border-layout

我需要动态设置一个 GridView 项目,我正在使用 LinearLayout 和应用圆角的背景可绘制对象,但我无法像这张图片那样只设置左上边框颜色.... Example

<img src="/image/R8lyH.png"/>

    <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>

最佳答案

grid_item.xml

<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>

类别适配器

pin = (PinnedGridItemView) relativeLayout.findViewById(R.id.pinned_grid_item);
pin.setColorCode(Color.RED);// Here I set any color that I want dynamically, the problem now is to solve top-left rounded corner

Result image

关于Android圆角边框颜色左上角仅动态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43290695/

相关文章:

macos - NSGridView 在 Storyboard中不可用?

java - 如果使用 Android 的两个项目具有相同的图像,则隐藏 GridView 中的项目

android - 支持不同的屏幕尺寸 - xml 未正确加载。可能的错误?

Android -.net WCF Generated Service 消费

java - Kindle Fire 和 GlSurfaceView.getHeight()

android - 自定义 ListView 适配器抛出 NullPointerException

android - 从 GridView 中的特定 SDCard 文件夹加载图像

android - Lint 改进后的可运行时崩溃

html - 如何在此布局中使内容100%高度和等高列?

javascript - 如何允许用户设置网格图像布局中的列数?