Android PageViewer顶部和底部的白色边框
我的图像没有完全适应屏幕。顶部和底部有白色边框 我的图像有700x1002 请有人帮我得到这些边缘,使图像/容器完全适合屏幕 layout.xml:Android PageViewer顶部和底部的白色边框,android,layout,Android,Layout,我的图像没有完全适应屏幕。顶部和底部有白色边框 我的图像有700x1002 请有人帮我得到这些边缘,使图像/容器完全适合屏幕 layout.xml: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/linearActions" >
<android.support.v4.view.ViewPager
android:id="@+id/tourImageViewPager"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</android.support.v4.view.ViewPager>
</FrameLayout>
<LinearLayout
android:id="@+id/linearActions"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/tour_bg"
android:orientation="horizontal" >
<Button
android:id="@+id/btnIdentify"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_marginBottom="24dp"
android:layout_marginLeft="30dp"
android:background="@color/buttonColorWhite"
android:layout_marginTop="27dp"
android:textSize="16sp"/>
<Button
android:id="@+id/btnGoHome"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_marginBottom="24dp"
android:layout_marginLeft="60dp"
android:layout_marginRight="30dp"
android:layout_marginTop="27dp"
android:background="@color/buttonColorBlue"
android:textSize="16sp"/>
</LinearLayout>
<RelativeLayout
android:id="@+id/relativeCircle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/linearActions"
android:layout_marginBottom="24dp"
android:background="@null" >
<com.viewpagerindicator.CirclePageIndicator
android:id="@+id/tourImageIndicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
app:fillColor="#027CC3"
app:pageColor="#CCCCCC" />
</RelativeLayout>
</RelativeLayout>
尝试更改您的
视图.setScaleType(ScaleType.FIT_CENTER)代码>至视图.设置缩放类型(缩放类型.中心裁剪)代码>有点晚了,但是上面提到的解决方案都不适合我。因此,我想分享我的解决方案,它非常有效。
如果在视图(ImageView)中设置ScaleType和Params,则可能会遇到LinerLayout/RelativeLayout的问题。
所以只需在viewpagerAdapter布局中设置ImageView的ScaleType,如下所示
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/sampleImage"
android:id="@+id/img_pager_item"
android:scaleType="center"
android:clickable="false"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/sampleImage"
android:id="@+id/img_pager_item"
android:scaleType="center"
android:clickable="false"
/>