我需要动态设置一个 GridView 项目,我正在使用 LinearLayout 和应用圆角的背景可绘制对象,但我无法像这张图片那样只设置左上边框颜色....
<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
关于Android圆角边框颜色左上角仅动态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43290695/