Android ScrollView 中放入 ImageView 导致的出现上下白边的问题?
2017-04-19 17:38
525 查看
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<include
android:id="@+id/***"
layout="@layout/***" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iv_guide_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
</ScrollView>
</LinearLayout>
这样在手机上面会出现ImageView上下都有一块空白,解决问题的做法就是在ImageView 中添加下面的一段代码:
[html] view
plain copy
![](https://code.csdn.net/assets/CODE_ico.png)
![](https://code.csdn.net/assets/ico_fork.svg)
scaleType=“fillXY”
这样也有弊端,图片会出现轻微缩放,导致失真。
或者
博客分类:
androidAndroid
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:fillViewport="true">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<ImageView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:src="@drawable/huge"
android:scaleType="fitCenter" android:layout_weight="1" />
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!-- Insert your content here -->
</LinearLayout>
</LinearLayout>
</ScrollView>
android:fillViewport="true" 必须设置的啊
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<include
android:id="@+id/***"
layout="@layout/***" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iv_guide_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
</ScrollView>
</LinearLayout>
这样在手机上面会出现ImageView上下都有一块空白,解决问题的做法就是在ImageView 中添加下面的一段代码:
[html] view
plain copy
![](https://code.csdn.net/assets/CODE_ico.png)
scaleType=“fillXY”
这样也有弊端,图片会出现轻微缩放,导致失真。
或者
让ImageView全部适应ScrollView
博客分类: androidAndroid
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:fillViewport="true">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<ImageView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:src="@drawable/huge"
android:scaleType="fitCenter" android:layout_weight="1" />
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!-- Insert your content here -->
</LinearLayout>
</LinearLayout>
</ScrollView>
android:fillViewport="true" 必须设置的啊
相关文章推荐
- Android ScrollView 中放入 ImageView 导致的出现上下白边的问题?
- Android ScrollView 中放入 ImageView 导致的出现上下白边的问题?
- Android ScrollView 中放入 ImageView 的出现上下空白
- 修复在“Android 在ScrollView中嵌入ViewPage后ViewPage不能很好的工作的问题解决”这篇博客中MyScrollView出现滑动一会就不会上下滑动的问题
- Android中ScrollView中嵌套ViewPager导致ViewPager不显示问题
- 解决ScrollView嵌套RexyclerView导致6.0以上手机ScrollView和RecyclerView可以同时滑动问题,5.1手机滑动卡顿问题(解决一个另一个又出现)
- Android Scrollview嵌套RecyclerView导致滑动卡顿问题解决
- Android在ScrollView中嵌套ViewPager以及ListView的可能出现的问题以及解决方案
- Android Bitmap太大导致ImageView不显示的问题
- Android 解决ScrollView嵌套RecyclerView导致滑动不流畅的问题
- Android Bitmap太大导致ImageView不显示的问题
- Android ViewGroup 子布局Layout id重名导致某些设备出现中断问题
- android 异常问题 Scrollview中嵌套webview出现大面积空白(第二次打开同一个地址下面才出现空白)
- Android中ScrollView中嵌套ViewPager导致ViewPager不显示的问题
- Android Bitmap太大导致ImageView不显示的问题
- Android 用ScrollView和HorizontalScrollView同时实现上下、左右滚动
- android:minSdkVersion =3改成7导致我的surfaceview的位置出现偏差。 报了数组越界异常。
- VideoView 在ScrollView中 滑动出现的问题
- JavaScript在Android的WebView中出现一个问题
- 关于android 设置TextView可点击出现覆盖的问题