我试图在水平滚动视图内的线性布局中获得2个(或更多)图像视图,这样每个图像都被缩放以适应屏幕高度,而不会扭曲图像(即屏幕上显示尽可能大的一个图像),滚动以查看下一个图像。
一旦第二个图像被添加,我得到两个小图像在彼此旁边(尺寸为217 *300 to对于这两个图像)。目前,我的activity_main.xml看起来如下..
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="match_parent"
>
<ImageView
android:id="@+id/image1"
android:src="@drawable/luke"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitCenter"
/>
<ImageView
android:id="@+id/image2"
android:src="@drawable/luke"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitCenter"
/>
</LinearLayout>
</HorizontalScrollView>
</FrameLayout>我在布局上尝试了match_parent、fill_parent、wrap_content的各种组合,在图像视图上尝试了所有的scaleTypes,并花了一天的时间浏览网络,寻找一个与我想要的相似的示例,但没有运气。
发布于 2013-08-15 09:15:25
我要说的是这两件事:
<ImageView
android:layout_height = "match_parent"
android:layout_width = "10dp" />这是棘手的部分。在运行时获取屏幕宽度,并将其设置为imageView。
https://stackoverflow.com/questions/18249520
复制相似问题