diff --git a/src/org/yaaic/adapter/DeckAdapter.java b/src/org/yaaic/adapter/DeckAdapter.java index 67ad3ef..158b981 100644 --- a/src/org/yaaic/adapter/DeckAdapter.java +++ b/src/org/yaaic/adapter/DeckAdapter.java @@ -186,7 +186,7 @@ public class DeckAdapter extends BaseAdapter */ public MessageListView renderConversation(Conversation conversation, ViewGroup parent) { - MessageListView list = new MessageListView(parent.getContext()); + MessageListView list = new MessageListView(parent.getContext(), parent); MessageListAdapter adapter = conversation.getMessageListAdapter(); if (adapter == null) { @@ -201,6 +201,7 @@ public class DeckAdapter extends BaseAdapter parent.getWidth() / 100 * 85, parent.getHeight() )); + list.setBackgroundResource(R.layout.rounded); list.setPadding(5, 5, 5, 5); list.setVerticalFadingEdgeEnabled(false); diff --git a/src/org/yaaic/view/MessageListView.java b/src/org/yaaic/view/MessageListView.java index 1d19958..2d7856b 100644 --- a/src/org/yaaic/view/MessageListView.java +++ b/src/org/yaaic/view/MessageListView.java @@ -23,7 +23,10 @@ package org.yaaic.view; import org.yaaic.adapter.MessageListAdapter; import android.content.Context; +import android.graphics.Canvas; import android.view.MotionEvent; +import android.view.View; +import android.widget.Gallery; import android.widget.ListView; /** @@ -36,15 +39,23 @@ public class MessageListView extends ListView public static final String TAG = "Yaaic/MessageListView"; private boolean delegate = true; + private View parent; + private int parentWidth; + private int parentHeight; /** * Create a new MessageListView * * @param context */ - public MessageListView(Context context) + public MessageListView(Context context, View parent) { super(context); + + this.parent = parent; + + parentWidth = parent.getWidth(); + parentHeight = parent.getHeight(); } /** @@ -70,6 +81,27 @@ public class MessageListView extends ListView return super.onTouchEvent(event); } } + + /** + * On draw + */ + @Override + protected void onDraw(Canvas canvas) + { + if (parent.getWidth() != parentWidth || parent.getHeight() != parentHeight) { + // parent size changed, resizing this child too + + parentWidth = parent.getWidth(); + parentHeight = parent.getHeight(); + + this.setLayoutParams(new Gallery.LayoutParams( + parent.getWidth() / 100 * 85, + parent.getHeight() + )); + } + + super.onDraw(canvas); + } /** * Get the adapter of this MessageListView