1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-08-13 16:53:50 -04:00

Resize MessageListView if parent's size has changed (fixing layout on using soft keyboard)

This commit is contained in:
Sebastian Kaspari 2010-03-20 21:49:46 +01:00
parent 70c9ab644b
commit 76222eefd3
2 changed files with 35 additions and 2 deletions

View File

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

View File

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