遇到问题,我无法解决:我想将来自 ListFragment 的许多图片裁剪为圆形。代码会更明确:
String[] countries = new String[] {
"Amel Mahmuzić",
"Laurent Meyer",
"Philipp Bellé",
"Dennis Pagano",
"Bill Gates",
"Steve Jobs",
"Jean Bonnot",
"Nicolas Sarkozy",
"Bob Marley",
"Thomas Pieronczyk"
};
int[] flags = new int[]{
R.drawable.amel_mahmuzic,
R.drawable.laurent,
R.drawable.phillip_belle,
R.drawable.dennis_pagano,
R.drawable.bill_gates,
R.drawable.steve_jobs,
R.drawable.jean_bonnot,
R.drawable.nicolas_sarkozy,
R.drawable.bob_marley,
R.drawable.thomas_pieronczyk,
};
String[] currency = new String[]{
"MoID GmbH",
"MoID GmbH",
"MoID GmbH",
"MoID GmbH",
"Microsoft",
"Apple",
"Pôle Emploi",
"Elysée",
"Weed Fabric",
"MoID GmbH"
};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
// Each row in the list stores country name, currency and flag
List<HashMap<String,String>> aList = new ArrayList<HashMap<String,String>>();
for(int i=0;i<10;i++){
HashMap<String, String> hm = new HashMap<String,String>();
hm.put("txt", countries[i]);
hm.put("cur", currency[i]);
hm.put("flag", Integer.toString(flags[i]) );
aList.add(hm);
}
// Keys used in Hashmap
String[] from = { "flag","txt","cur" };
// Ids of views in listview_layout
int[] to = { R.id.flag,R.id.txt,R.id.cur};
// Instantiating an adapter to store each items
// R.layout.listview_layout defines the layout of each item
SimpleAdapter adapter = new SimpleAdapter(getActivity().getBaseContext(), aList, R.layout.image_item, from, to);
setListAdapter(adapter);
return super.onCreateView(inflater, container, savedInstanceState);
}
}
好的,我知道你会说什么:“这不是标志,不是货币……”示例来自互联网并正在运行。我只想知道如何将我的图片裁剪为一个圆圈。
如果没有人找到,是否有人知道如何用一个正方形和一个透明的圆圈进行叠加,点击时颜色会发生变化?
如果你想看看它的样子: