Luk*_*nda 4 android android-layout picasso android-bitmap
我对Picasso库缩放有严重问题.问题是我有一个由3个主视图和一些按钮组成的布局.意见如下:
ImageView 50%mapView 20%EditTextView 30%
我想在不留空白的情况下将未知分辨率的图片加载到该imageView中.我试图使用.fit().centerInside,但只留下两侧的空白区域.这就是我的布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_below="@+id/photo1"
android:weightSum="10">
<ImageView
android:id="@+id/photo1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="5"
android:background="#75aea7ab" />
<com.google.android.gms.maps.MapView
android:id="@+id/map2"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="2" />
<EditText
android:id="@+id/edittext"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_marginBottom="15dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp"
android:layout_weight="3"
android:background="#00000000"
android:gravity="top|left"
android:inputType="textMultiLine"
android:textColor="#ff000000"
android:textSize="15sp" />
</LinearLayout>
<ImageButton
android:id="@+id/post"
android:layout_width="@dimen/fab_button_diameter"
android:layout_height="@dimen/fab_button_diameter"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="end"
android:layout_marginBottom="300dp"
android:background="@drawable/fab_shape"
android:src="@drawable/forward"
android:text="Post!"
android:tint="@android:color/white" />
<Button
android:id="@+id/camera"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="75dp"
android:layout_marginTop="100dp"
android:background="@drawable/camera" />
<Button
android:id="@+id/gallery"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="75dp"
android:layout_marginTop="100dp"
android:background="@drawable/gallery" />
Run Code Online (Sandbox Code Playgroud)
您是否尝试在加载图像后设置ScaleType?
mPicasso.load("yourUrl")
.into(yourImageView, new Callback() {
@Override
public void onSuccess() {
yourImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);//Or ScaleType.FIT_CENTER
}
@Override
public void onError() {
//nothing for now
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1812 次 |
| 最近记录: |