2012-11-07 92 views
3
    <?xml version="1.0" encoding="utf-8"?> 
        <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:orientation="horizontal" 

         android:padding="10dip" 
         android:background="@drawable/greybox" 
         > 

        <ImageView 
          android:id="@+id/profile_pic" 
          android:layout_width="60dp" 
          android:layout_height="60dp" 
          android:layout_marginTop="5dp" 
          android:layout_alignParentTop="true" 
          android:layout_alignParentLeft="true" 
          /> 

        <RelativeLayout 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:orientation="vertical" 
         android:layout_marginLeft="20dp" 


         android:layout_toRightOf="@+id/profile_pic"> 

         <TextView 
          android:id="@+id/name" 
          android:layout_width="fill_parent" 
          android:layout_height="wrap_content" 
          android:text="Kumar" 
          android:textSize="18dp" 
          android:textColor="#4c3f38" 
          android:layout_alignParentLeft="true" 


          /> 


         <TextView 
          android:id="@+id/msg" 
          android:layout_width="fill_parent" 
          android:layout_height="wrap_content" 
          android:textSize="15dp" 
          android:layout_below="@+id/name" 
           android:textColor="#7b7674" 

          /> 



         <LinearLayout 
         android:id="@+id/picpostlayout" 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:layout_gravity="top|center" 
         android:layout_marginTop="5dp" 
         android:layout_below="@+id/msg" 
         android:orientation="vertical" > 

         <ImageView 
          android:id="@+id/picpost" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:adjustViewBounds="true" 
          android:scaleType="fitXY" 
          android:src="@null" /> 
        </LinearLayout> 

         <TextView 
          android:id="@+id/comment" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:textSize="15dp" 
          android:layout_marginTop="5dp" 
          android:layout_marginRight="5dp" 
          android:layout_below="@+id/picpostlayout" 
          android:layout_alignParentRight="true" 

          android:textColor="#000000" 

          /> 


        </RelativeLayout> 
        </RelativeLayout> 


    Here is my complete xml.I am using the linearlayout to show the posted picture,but it is still showing very small size.I used two relative layouts, one for complete xml and another for name,message,postpicture. 
    Here is also my screenshot to the above given xml file.I am getting the large image but I cant able to show the same size,it is showing very small size. 
    I got an post picture from facebook api,I am getting very large image as I used _n.jpg,but when I tried to display using imageview it is showing very small size. 

     ][1] 


      [1]: http://i.stack.imgur.com/63nTO.png 

Here is the code of getting posted picture from facebook api.If the post object has picture field then I get that picture and changed that into large image and I added that to my ArrayList pic. 

      if(jsonObject.has("picture")) 
      { 
      String fetchedURL = jsonObject.getString("picture"); 
      String getFeedPicture = fetchedURL.replaceAll("_s.jpg", "_n.jpg"); 
      pic.add(getFeedPicture); 
      } 

然後我發送該ArrayList到我的適配器,我通過發送到imageloader類將該圖像設置爲imageview。 這是我的裝載機類參考圖像加載程序,我將圖像設置爲imageview.I設置它在我的適配器類。如何增加facebook api發佈圖片的大小?

imageLoader.DisplayImage(postimage.get(position).replace(「」,「%20」),postimg);

+0

你可以張貼一些代碼來展示你是如何獲取的圖像? –

+0

webserv =「https://graph.facebook.com/me/home?access_token=」+ accesstoken; pic.add(jsonObject.getString( 「圖片」)); – veerendra

+0

你還可以發佈它的外觀截圖嗎? –

回答

2

進行此修改到您當前密碼:

String fetchedURL = JOFeeds.getString("picture"); 
String getFeedPicture = fetchedURL.replaceAll("_s.jpg", "_n.jpg"); 
pic.add(getFeedPicture); 

這是從你的飼料質量更好的圖片最簡單的方法。這段代碼的重點在於,默認情況下,Facebook API會返回一個小圖片。通過用_n.jpg替換_s.jpg爲您提供更大的圖像。

我在整個應用程序中使用此代碼,它每次都像魅力一樣工作。

Sample Image

以及相應的代碼是這樣的:

<LinearLayout 
    android:id="@+id/linlaFeedPicture" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="top|center" 
    android:layout_margin="1dp" 
    android:gravity="center" 
    android:orientation="vertical" > 

    <ImageView 
     android:id="@+id/imgvwFeedPicture" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:adjustViewBounds="true" 
     android:scaleType="fitXY" 
     android:src="@null" /> 
</LinearLayout> 
+0

是的,我用它,但當我保持wrap_content它顯示非常小的圖像這裏是我的xml內容 veerendra

+0

嘗試在'LinearLayout'中用'android:layout_w'嵌套'ImageView'設置爲** fill_parent ** –

+0

@ user1761316:我正在使用我的應用程序中的示例圖像更新答案,其中我使用了給出的解決方案。 –