2

I would really appreciate a little assistance in getting my ui complete.

I am trying to implement my own newsfeed list from facebook. The problem I have is for posts which are photo type or video type. The image resolution they send to preview the post is different each time depending on the resolution of the image initially (i think).

What im wanting to do is display this image in the center of a listview like the facebook app does, whilst having a textview at the bottom of the imageview.

My attempts so far only seem to overlay the textview at the bottom of some of the imageviews (depending on their size) and is distorting the image probably due to my width and height values.

This is what i currently trying

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:background="#ffffff"
android:layout_width="fill_parent" android:layout_height="wrap_content">


<ImageView android:id="@+id/thumbImage" 
    android:padding="10dp"
    android:focusable="true"
    android:background="#ffffff"
    android:layout_width="200dp"
    android:scaleType="centerInside"
        android:layout_height="150dp"
    android:layout_centerInParent="true"
      />

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="180dp"
android:layout_height="50dp"

android:background="#AA000000"
   android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"


android:layout_width="fill_parent" android:layout_height="fill_parent">
<TextView
    android:id="@+id/imagename" 
android:layout_width="180dp"
android:layout_height="wrap_content" 

android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"

android:textColor="#ffffff"

android:text="" /></RelativeLayout></LinearLayout>

and i am also doing this

imageview.setScaleType(ImageView.ScaleType.CENTER_CROP);

Thanks.

4

1 回答 1

0

尝试以下操作:

<?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="#ffffff" >

    <RelativeLayout
        android:layout_width="180dp"
        android:layout_height="80dp"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:background="#ff0000" >

        <ImageView
            android:id="@+id/thumbImage"
            android:layout_width="wrap_content"
            android:layout_height="50dp"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:background="#0000ff"
            android:focusable="true"
            android:padding="0dp"
            android:scaleType="centerInside"
            android:src="@drawable/img3" />

        <TextView
            android:id="@+id/imagename"
            android:layout_width="wrap_content"
            android:layout_height="30dp"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:text="Image description is too large that it can not be fit in one line" />

    </RelativeLayout>

</RelativeLayout>
于 2012-07-20T14:45:34.977 回答