I am developing an SMS application in which i have to save a received SMS in my application. I use a custom list view to save the SMS content, SMS sender and SMS date. This works completely fine when the incoming SMS is short i.e. 4 5 lines. But the problem is that if the SMS is long i.e. more than 5 6 lines then the listview not showing full SMS. It shows first 4 5 lines but cut the next part of the SMS. I don't know what to do and completely stuck.
Here is my custom listview content
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="@+id/product_icon"
android:layout_width="40dp"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="2dp"
android:padding="3dp"
android:src="@drawable/personn"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center|center_vertical"
android:orientation="vertical"
android:paddingLeft="2dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center|center_vertical"
android:orientation="horizontal"
android:paddingLeft="0dp"
>
<TextView
android:id="@+id/txt_msgTO"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginTop="15dp"
android:lineSpacingExtra="3dp"
android:textSize="16sp"
android:text="Ahtesham"
android:textStyle="bold"
android:textColor="#070B19"
android:minLines="1"
android:layout_marginRight="5dp"
android:gravity="center_vertical"
/>
<TextView
android:id="@+id/date"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:lineSpacingExtra="3dp"
android:textSize="10sp"
android:text="Ahtesham"
android:textStyle="bold"
android:gravity="right"
android:layout_marginRight="5dp"
android:textColor="#070B19"
/>
</LinearLayout>
<TextView
android:id="@+id/txt_messageContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:lineSpacingExtra="3dp"
android:textColor="#585858"
android:textSize="13sp"
android:singleLine="true"
android:text="Heloo How are you"
android:layout_marginTop="0dp"
android:layout_marginRight="5dp"
android:gravity="center_vertical"
/>
</LinearLayout>
<TextView
android:id="@+id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
please look at id "message content" text view, the problem would be there i think
I am calling that main listview in the activity. xml code for main list view is
<ListView
android:id="@+id/messageList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:cacheColorHint="@null"
android:listSelector="@android:color/transparent"
android:layout_marginBottom="45dp" />
and Finally I am fetching inbox messages in this list view
public void populateMessageList() {
fetchInboxMessages();
messageListAdapter = new SmsList(this,R.layout.smscontent, recordsStored);
messageList.setAdapter(messageListAdapter);
}
smscontent is the name of custom listview content Please Help!!
Use this Attributes in your Text View
for txt_messageContent.
android:maxLines="10"
android:lines="10"
android:singleLine="false"
EDIT 1:
Change this.
android:layout_height="wrap_content"
EDIT 2:
Add this.
android:inputType="textMultiLine"
EDIT 3:
Changed the Layout
apply this.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/product_icon"
android:layout_width="40dp"
android:layout_height="50dp"
android:layout_marginLeft="2dp"
android:layout_marginTop="10dp"
android:padding="3dp"
android:src="@drawable/ic_add_black" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center|center_vertical"
android:orientation="vertical"
android:paddingLeft="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center|center_vertical"
android:orientation="horizontal"
android:paddingLeft="0dp">
<TextView
android:id="@+id/txt_msgTO"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginRight="5dp"
android:layout_marginTop="15dp"
android:gravity="center_vertical"
android:lineSpacingExtra="3dp"
android:minLines="1"
android:text="Ahtesham"
android:textColor="#070B19"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/date"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_marginTop="15dp"
android:gravity="right"
android:lineSpacingExtra="3dp"
android:text="Ahtesham"
android:textColor="#070B19"
android:textSize="10sp"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="@+id/txt_messageContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginRight="5dp"
android:layout_marginTop="0dp"
android:gravity="center_vertical"
android:lineSpacingExtra="3dp"
android:singleLine="false"
android:text="Heloo How are you,Heloo How are you,Heloo How are you,Heloo How are you,Heloo How are you,Heloo How are youHeloo How are you,Heloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are you,Heloo How are you,Heloo How are you,Heloo How are you,Heloo How are you,Heloo How are youHeloo How are you,Heloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are you,Heloo How are you,Heloo How are you,Heloo How are you,Heloo How are you,Heloo How are youHeloo How are you,Heloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are you,Heloo How are you,Heloo How are you,Heloo How are you,Heloo How are you,Heloo How are youHeloo How are you,Heloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are you,Heloo How are you,Heloo How are you,Heloo How are you,Heloo How are you,Heloo How are youHeloo How are you,Heloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are youHeloo How are you"
android:textColor="#585858"
android:textSize="13sp" />
</LinearLayout>
</LinearLayout>
Note: You can change values of maxLines and lines
as you want.