2015-05-13 70 views
1

我有兩個項目,我創建了一組自定義cards,擴展了card類,然後我將它們插入StaggeredViewCardlib圓角

我的問題是,在其中一個項目中,卡角自動舍入,而另一個不是!

此外在第二個項目中,滾動發生在適合和開始!

這裏是我的代碼:

@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; 
} 

DeviceCardListclass

cardslib_inner_layoutxml file

staggered_view.xmlxml file

回答

2

解決它! 原來,爲了設置卡與cardslib角落,就必須重寫此值:從這個文件

<dimen name="cardview_default_radius">yourRadius</dimen> 
<dimen name="card_background_default_radius">"yourRadius"</dimen> 

dimens.xml

對我來說,只需要覆蓋card_background_default_radius