gpt4 book ai didi

android - 如何以编程方式更改形状纯色?

转载 作者:搜寻专家 更新时间:2023-11-01 09:33:29 24 4
gpt4 key购买 nike

<分区>

如何更改 <solid android:color= />以编程方式?

我定义了一个自定义形状元素:我的项目.xml:

<shape android:shape="oval">
<solid android:color="#FFFF0000"/>
</shape>

并在另一个布局中重用它: GridView .xml:

<LinearLayout>
<ImageView ... android:src="@drawable/my_item"
android:id="@+id/myitemid" />
</LinearLayout>

以下不起作用:

public class ShapeItemAdapter extends BaseAdapter {

@Override
public View getView(int i, View view, ViewGroup viewGroup) {
view = inflter.inflate(R.layout.grid_view, null);
ImageView shape = (ImageView) view.findViewById(R.id.myitemid);
shape.setBackgroundColor(0xBCCACA); //does not work
}
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com