是否有可能覆盖图标这么多形状的Android中
问题描述:
我使用图层列表创建按钮形状,并添加图像是否有可能覆盖图标这么多形状的Android中
myshape.xml
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#FDD400"/>
<corners android:radius="15dp" />
</shape>
</item>
<item>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/buy_card_24dp"
android:gravity="center" />
</item>
</layer-list>
我添加此myshape.xml
为使用adapter
类,因为这button
的appcompact button
的背景资源是gridview
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.menu_view_item, null);
TextView textView = (TextView) v.findViewById(R.id.menuName);
AppCompatButton appCompatButton = (AppCompatButton) v.findViewById(R.id.menuImage);
appCompatButton.setBackgroundResource(menuList.get(position).getMenuImage());
textView.setText(menuList.get(position).getMenuName());
return v;
}
和我指定的myshape.xml
文件中的主要class
像
ArrayList<MenuGridItem> menuList=new ArrayList<>();
menuList.add(new MenuGridItem("Home",R.drawable.myshape));
但button
图标太小,是可以覆盖的图标形状有些%的
答
我使用24dp材料图标现在我改为48dp ...现在图标大小几乎可以...