B
Binbose
Ambitioniertes Mitglied
- 0
Hallo Leute,
für einen kleinen Chat möchte ich, dass meine Sprechblasen rechts sind, bekomme es aber mit einem RelativeLayout einfach nicht hin. Hier ist das Sprechblasen Layout:
Und hier meine getView() Methode, ich habe da schon alles mögliche versucht, deshalb ist es ein bisschen unaufgeräumt:
Ich hoffe ihr könnt mir helfen, danke schonmal im vorraus.
mfg
für einen kleinen Chat möchte ich, dass meine Sprechblasen rechts sind, bekomme es aber mit einem RelativeLayout einfach nicht hin. Hier ist das Sprechblasen Layout:
HTML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sprechblasenlayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:background="@drawable/speech_bubble_green"
android:orientation="vertical" >
<TextView
android:id="@+id/tvName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Peter"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/tvZeitstempel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/message_text"
android:layout_toRightOf="@+id/message_text"
android:text="14:32"
android:textSize="10sp" />
<TextView
android:id="@+id/message_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tvName"
android:layout_below="@+id/tvName"
android:layout_margin="4dip"
android:shadowDx="1"
android:shadowDy="1"
android:text="Medium Text"
android:textSize="20sp" />
</RelativeLayout>
Und hier meine getView() Methode, ich habe da schon alles mögliche versucht, deshalb ist es ein bisschen unaufgeräumt:
Code:
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View listenEintrag = inflater.inflate(R.layout.chat_listeneintrag, parent, false);
DataModelNachricht message = (DataModelNachricht) values.get(position);
RelativeLayout sprechblase = (RelativeLayout)listenEintrag.findViewById(R.id.sprechblasenlayout);
TextView Nachricht = (TextView) listenEintrag.findViewById(R.id.message_text);
Nachricht.setText(message.getNachricht());
TextView Name = (TextView)listenEintrag.findViewById(R.id.tvName);
Name.setText(message.getAbsender());
TextView Zeitstempel = (TextView)listenEintrag.findViewById(R.id.tvZeitstempel);
Zeitstempel.setText(message.getZeitstempel());
LayoutParams lp = (LayoutParams) sprechblase.getLayoutParams();
if(message.getAbsenderID()== MeineID)
{
sprechblase.setBackgroundResource(R.drawable.speech_bubble_green);
sprechblase.setGravity(Gravity.RIGHT);
}
//If not mine then it is from sender to show orange background and align to left
else
{
sprechblase.setBackgroundResource(R.drawable.speech_bubble_orange);
sprechblase.setGravity(Gravity.LEFT);
}
//sprechblase.setLayoutParams(lp);
return listenEintrag;
}
Ich hoffe ihr könnt mir helfen, danke schonmal im vorraus.
mfg