2016-04-07 12 views
2

FacebookでFrescoライブラリのアプリを構築しています。フレスコ画、さまざまなデバイスの画像を拡大する方法

私は私のアプリは、異なるデバイス間で使用可能になる場合、フレスコを使用してビューを実装する方法を理解しようとする問題を抱えています。添付の画像でわかるように、私はNexus6とNexusOneとNexus7を持っています。

それらのすべてが同じフレスコDrawee、(200dpのx 200dp)を持っています。私がフレスコ画のドキュメントを読んだので、イメージのサイズを固定することは必須で、必須です。しかし、私はImageViewがFrescoを使って画像の幅の50%を使っているのと同じように簡単に何かを達成することができますか?

所望の結果は、(幅の点で)画面の半分を使用して画像を有し、異なるテキスト(図示タイトル+説明)のためのスペースの残りの部分を残すことであろう。

は、通常、私は、この使用して軽量の、しかし私は図書館でこれを達成するかどうかはわかりませんんでしょうか、ベストプラクティスがどうなりますか。 this質問(およびドキュメント)に基づいて

、私はリスナーを追加することが最善の選択肢であるかはわかりません。私は、このライブラリをFacebookや他のアプリケーションがどのように使っているのかを理解していないのです。予め

おかげ

Nexus One Nexus 6 enter image description here

この画像の示すコードは、基本的に以下の通りである:

  <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:weightSum="10"> 

      <com.facebook.drawee.view.SimpleDraweeView 
       android:id="@+id/my_image_view" 
       android:layout_width="200dp" 
       android:layout_height="200dp" 

       fresco:actualImageScaleType="focusCrop" 
       fresco:backgroundImage="@drawable/user_icon" 
       fresco:fadeDuration="300" 
       fresco:placeholderImage="@color/common_action_bar_splitter" 
       fresco:placeholderImageScaleType="fitCenter" /> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" 
       android:layout_toRightOf="@+id/my_image_view"> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:textSize="20sp" 
        android:text="Title 1" /> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:textSize="15sp" 
        android:textColor="@color/menu_color" 
        android:text="Description 1" /> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:textSize="20sp" 
        android:text="Title 2" /> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:textSize="15sp" 
        android:textColor="@color/menu_color" 
        android:text="Description 2" /> 


      </LinearLayout> 


     </RelativeLayout> 

UPDATE:

Iはまた、Dフルスクリーンの画像を取得する方法はわかりません。ディメンションを指定するかmatch_parentを使用する必要があるが、両方でmatch_parentを使用すると親全体が使用される場合、Facebookの画像を示す画像のようなものを取得するにはどうすればよいですか。

私はこの問題は、絵のために画面の50%を使用してのデザインパターンである場合しかし、私はまだ思ったんだけど、@Gueorguiオブレゴンのは良いアイデアだと思います。例えば、同じ寸法(例えばMDPI)の2つの携帯電話モデルを取るが、そのうちの1つはもう一方のものよりも少し広い。私は1つの携帯電話よりも画面の半分を取る次元のアプローチを使用して、他の1つでは、それは少し/より少なくかかります。

まとめ:問題はどこですか?ビューをデザインするとき、パーセンテージを悪い考えで考えていますか?アンドロイドがパーセンテージを使用するのは悪い設計思想だとデザイナーに伝えるべきでしょうか?もっと重要なのは、Facebookが最後の写真(画面の33%を使う場所)のようなものをどうやって実現できるのか?

Image % on Facebook

+0

私の答えはあなたを助けますか? –

答えて

1

Facebook Image

あなた 異なる画面ごとに異なる フォルダの dimensions.xmlを使用することができます。

res/values/dimensions.xml 
res/values-sw600dp/dimensions.xml -> 7+ inches 
res/values-sw720dp/dimensions.xml -> 10+ inches 

RES /値/ dimensions.xml

<dimen name="my_image_view_width">200dp</dimen> 
<dimen name="my_image_view_height">200dp</dimen> 

RES /値-sw720dp/dimensions.xml各寸法に所望の値を追加

<dimen name="my_image_view_width">400dp</dimen> 
<dimen name="my_image_view_height">400dp</dimen> 

次に、あなたのSimpleDraweeView

このような
<com.facebook.drawee.view.SimpleDraweeView 
    android:id="@+id/my_image_view" 
    android:layout_width="@dimen/my_image_view_width" 
    android:layout_height="@dimen/my_image_view_height" 
    fresco:actualImageScaleType="focusCrop" 
    fresco:backgroundImage="@drawable/user_icon" 
    fresco:fadeDuration="300" 
    fresco:placeholderImage="@color/common_action_bar_splitter" 
    fresco:placeholderImageScaleType="fitCenter" /> 

で210と@dimen/my_image_view_heightは、この情報がお役に立てば幸いです!

+0

あなたのお返事ありがとうございますGueorgui、私はまだこのアプローチに関するいくつかの質問があるので、私は私の答えを更新しました。すべてのディメンションで固定dpを使用するよりも確かに優れていると思いますが、これが最良の方法であるかどうかは疑問です。 – Waclock

関連する問題