0
xml file 

    RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="@drawable/list_selector" 
    android:orientation="horizontal" 
    android:padding="5dip">

    <LinearLayout 
    android:id="@+id/thumbnail" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_marginRight="5dip" 
    android:padding="3dip">
   <ImageView 
      android:id="@+id/icon" 
      android:layout_width="80dip" 
      android:layout_height="80dip" 
      android:layout_gravity="top" 
      android:contentDescription="@string/app_name" 
      android:src="@drawable/high" /> 
   </LinearLayout>

   <TextView 
      android:id="@+id/newsaddress" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignTop="@+id/icon" 
      android:layout_toRightOf="@+id/icon" 
      android:layout_marginLeft="75dip" 
      android:layout_centerVertical="true" 
      android:paddingBottom="9dip" 
      android:text="Cebu City" 
      android:textColor="#040404" 
      android:textSize="25dip" 
      android:textStyle="bold" 
      android:typeface="sans" /> 

   <TextView 
      android:id="@+id/newsdate" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/newsaddress" 
      android:layout_alignLeft="@+id/newsaddress" 
      android:layout_alignBottom="@+id/icon" 
      android:paddingTop="5dip" 
      android:layout_centerHorizontal="true" 
      android:text="January 1 2000" 

      android:textColor="#343434" 
      android:textSize="15dip" /> 
    <TextView 
      android:id="@+id/newstitle" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:layout_centerVertical="true" 
      android:layout_marginRight="20dip" 
      android:layout_alignTop="@+id/newsaddress" 
      android:text="Fire" 
      android:textSize="30dip" /> 
   </RelativeLayout>

list xml 
    <?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="match_parent"
    android:orientation="vertical">


    <ListView
        android:id="@+id/newslist"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />

    </LinearLayout>

i have this list view with an image and a couple of text views my problem is that when the text are too long they over lap on each other ive tried a couple of post like this How to adjust text font size to fit textview and this one Auto Scale TextView Text to Fit within Bounds but they did work for me how can i possible solve this problem here is the result of this program the over lapping text is from 2nd text view

Community
  • 1
  • 1
Giant
  • 1,619
  • 7
  • 33
  • 67

1 Answers1

1

You have a few little problems.

These lines won't work correctly:

  android:layout_alignTop="@+id/icon" 
  android:layout_toRightOf="@+id/icon

You can't reference an id from inside a LinearLayout for lining up stuff in a relative layout, even if they are both in the same big layout.

I changed some of the layout, and put in some bigger strings to test it, and changed some of your padding, as it was kind of screwy because of the icon stuff, most likely.

enter image description here

This is the code I used. I'm sure its not exactly what you wanted, but I think it points out how to remedy a few problems.

<?xml version="1.0" encoding="utf-8"?>

        <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@color/grey"
        android:orientation="horizontal"
        android:padding="5dip">

<LinearLayout
        android:id="@+id/thumbnail"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginRight="5dip"
        android:padding="3dip">
    <ImageView
            android:id="@+id/icon"
            android:layout_width="80dip"
            android:layout_height="80dip"
            android:layout_gravity="top"
            android:contentDescription="@string/app_name"
            android:background="@color/white" />
</LinearLayout>

<TextView
android:id="@+id/newsaddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/thumbnail"
android:layout_toRightOf="@+id/thumbnail"
android:layout_marginLeft="2dp"
android:layout_centerVertical="true"
android:paddingBottom="0dip"
android:text="Cebu City in the south of france"
android:textColor="#040404"
android:textSize="25dip"
android:textStyle="bold"
android:typeface="sans" />

<TextView
android:id="@+id/newsdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/newsaddress"
android:layout_alignLeft="@+id/newsaddress"
android:paddingTop="1dip"
android:layout_centerHorizontal="true"
android:text="January 1 2000"

android:textColor="#343434"
android:textSize="15dip" />
<TextView
android:id="@+id/newstitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="20dip"
android:layout_below="@id/newsdate"
android:text="Fire is exploding all around us now"
android:textSize="30dip" />
        </RelativeLayout>
HalR
  • 11,411
  • 5
  • 48
  • 80
  • is it possible to put the fire exploding text view to the right of cebu city?just wanted to know how coz i've tried auto resize its a post here too but it didnt work – Giant Apr 12 '13 at 03:36
  • The only way you can do that would be to set the Cebu City text to a certain size--giving it a width of 100 or 200 dp, or something like that. As long as it has unlimited height, it will wrap if needed. Then you can align the other text to the right of it, and then match up with the top of the cebu city text. – HalR Apr 12 '13 at 03:39
  • thank you mate solved..i put in single i hope it works lol by the way how can i put (...) thing on if there are still text that follows? – Giant Apr 12 '13 at 03:50
  • You can get the dots with this: android:ellipsize="end" android:maxLines="1" and if you want it to scroll you can add this: android:scrollHorizontally="true" – HalR Apr 12 '13 at 03:54
  • it worked perfectly thank you...i have another question do you know how to change an activity to service its a bit complicated for my level but it is included in my project so i have to know how to do it...i have a gps tracking but its just an activity they said it needs to be in service. – Giant Apr 12 '13 at 04:05
  • Sorry, I've never done anything with it. Just word another StackOverflow question with it (a service, or gps), I bet someone will help you. – HalR Apr 12 '13 at 04:09