我正在用Facebook编写Fresco图书馆的应用程序。壁画,如何缩放不同设备的图像
我有问题试图了解如何使用Fresco实现视图,如果我的应用程序可以在不同设备间使用。正如您在附件中看到的,我有一个Nexus6,一个NexusOne和一个Nexus7。
它们都有相同的Fresco Drawee(200dp x 200dp)。正如我读过Fresco的文档,有必要和必须修复图像大小。然而,我无法理解如何实现像使用Fresco使用50%图像宽度的ImageView一样简单的操作。
想要的结果是使图像使用一半的屏幕(宽度方面),并为不同的文本保留其余空间(显示标题+说明)。
通常情况下,我会用重量来做这个,但是我不知道如何用库来实现这个,或者最佳实践是什么。
基于this问题(和文档),我不确定是否添加侦听器是最佳选择。我只是无法理解Facebook或其他使用这个库的应用程序是如何为不同的设备做的。
预先感谢
此图像的显示的代码是基本上如下:
<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:
我还d不知道如何获得全屏图像。如果我们必须指定维度,或者使用match_parent,但是在两者上使用match_parent都会使用整个父级,那么如何获得类似于显示Facebook图像的图像呢?
我相信@Gueorgui Obregon's是个好主意,但是我仍然想知道如果问题是使用50%的屏幕图片的设计模式。例如,拿两个尺寸相同的手机型号(例如MDPI),但其中一个比另一个宽一点。使用尺寸方法我会比在一个移动设备上占用一半的屏幕,但在另一个移动设备上,它需要多一点/少一点。
总结:问题在哪里?在设计视图时,是否认为百分比是一个坏主意?我应该告诉我的设计师,对于android来说,使用百分比是一个糟糕的设计理念吗?更重要的是,Facebook如何实现最后一张照片(图片使用大约33%的屏幕)?
我的回答对您有帮助吗? –