カードの前半だけが表示され、残りの半分が次のトランプで覆われるように、ゲーム内のトランプをオーバーラップさせようとしています。完全に見えるはずのカードは、最後/右端のカードだけです。
次のコードをframelayoutとrelativelayoutの両方で使用しましたが無駄になりました。誰かがいくつかの提案を提供できますか?
public int shouldShow(int numberOfCards, int card, int id)
{
if(card == -1)
hide(id);
else
{
findViewById(id).setBackgroundDrawable(deckimages[card]);
//findViewById(id).offsetLeftAndRight(findViewById(id).getWidth()* numberOfCards / 2);
show(id);
//findViewById(id).setPadding(findViewById(id).getWidth()* numberOfCards / 2, 0,0,0);
return numberOfCards+1;
}
return numberOfCards;
}
パディングとオフセットの方法を試してみましたが、どちらも機能していません。しかし、getwidth()メソッドとgetmeasuredwidth()メソッドが0を返していることにも気づきました。
どのレイアウトを使用する必要があるのか、getwidth関数が機能しない理由についての提案はありますか?
xmlコードは以下のとおりです...これよりも多くの画像がありますが、これは私がテストしていたものです
<RelativeLayout android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/RelativeLayout1">
<ImageView android:id="@+id/imageView2" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView>
<ImageView android:id="@+id/imageView3" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView>
</RelativeLayout>