Cardslib 圆角
Cardslib round corners
我有两个项目,我在其中创建了一组自定义 cards
扩展 card
class,然后将它们插入 StaggeredView
。
我的问题是,在其中一个项目中,卡片的边角会自动变圆,而在另一个项目中则不会!
此外,在第二个项目中,滚动时断时续!
这是我的代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.staggered_grid);
List<Tour> data = createList(10);
ArrayList<Card> cardes = initCards(data);
mCardArrayAdapter = new CardGridStaggeredArrayAdapter(ListViewPrenota.this, cardes);
CardGridStaggeredView mGridView = (CardGridStaggeredView)
ListViewPrenota.this.findViewById(R.id.carddemo_extras_grid_stag);
if (mGridView != null) {
mGridView.setAdapter(mCardArrayAdapter);
}
}
private ArrayList<Card> initCards(List<Tour> data){
ArrayList<Card> cards = new ArrayList<>();
for(int i = 0; i <= data.size()-1; i++ ){
DeviceCardList card = new DeviceCardList(this, R.layout.cardslib_inner_layout, data.get(i));
cards.add(card);
}
return cards;
}
DeviceCardList
: class
cardslib_inner_layout
: xml file
staggered_view.xml
: xml file
解决了!
事实证明,为了用 cardslib 设置卡片的角,有必要覆盖这个值:
<dimen name="cardview_default_radius">yourRadius</dimen>
<dimen name="card_background_default_radius">"yourRadius"</dimen>
来自此文件:dimens.xml
对我来说,只需要覆盖 card_background_default_radius
我有两个项目,我在其中创建了一组自定义 cards
扩展 card
class,然后将它们插入 StaggeredView
。
我的问题是,在其中一个项目中,卡片的边角会自动变圆,而在另一个项目中则不会!
此外,在第二个项目中,滚动时断时续!
这是我的代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.staggered_grid);
List<Tour> data = createList(10);
ArrayList<Card> cardes = initCards(data);
mCardArrayAdapter = new CardGridStaggeredArrayAdapter(ListViewPrenota.this, cardes);
CardGridStaggeredView mGridView = (CardGridStaggeredView)
ListViewPrenota.this.findViewById(R.id.carddemo_extras_grid_stag);
if (mGridView != null) {
mGridView.setAdapter(mCardArrayAdapter);
}
}
private ArrayList<Card> initCards(List<Tour> data){
ArrayList<Card> cards = new ArrayList<>();
for(int i = 0; i <= data.size()-1; i++ ){
DeviceCardList card = new DeviceCardList(this, R.layout.cardslib_inner_layout, data.get(i));
cards.add(card);
}
return cards;
}
DeviceCardList
: class
cardslib_inner_layout
: xml file
staggered_view.xml
: xml file
解决了! 事实证明,为了用 cardslib 设置卡片的角,有必要覆盖这个值:
<dimen name="cardview_default_radius">yourRadius</dimen>
<dimen name="card_background_default_radius">"yourRadius"</dimen>
来自此文件:dimens.xml
对我来说,只需要覆盖 card_background_default_radius