小编Luk*_*nda的帖子

Android毕加索缩放照片更大或适合imageView(无空白区域)

我对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)

android android-layout picasso android-bitmap

4
推荐指数
1
解决办法
1812
查看次数

RecyclerView滚动后选择错误的项目onClick

我有一个基于RealmRecyclerViewAdapter的recyclerviewAdapter.

public class PlaceAdapter extends RealmRecyclerViewAdapter<Place, PlaceAdapter.PlaceViewHolder> implements Filterable {

private static final String TAG = PlaceAdapter.class.getSimpleName();

static class PlaceViewHolder extends RecyclerView.ViewHolder {

    TextView name;

    PlaceViewHolder(View itemView) {
        super(itemView);
        name = (TextView) itemView.findViewById(R.id.name);
    }
}

private Realm realm;
private static RecyclerViewClickListener itemListener;
private TextView lastTextView;

public PlaceAdapter(@NonNull Context context, @Nullable OrderedRealmCollection data, boolean autoUpdate, RecyclerViewClickListener listener,
                    Realm realm) {
    super(context, data, autoUpdate);
    this.realm = realm;
    itemListener = listener;
}

@Override
public PlaceViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
    View itemView = …
Run Code Online (Sandbox Code Playgroud)

android realm android-recyclerview

3
推荐指数
1
解决办法
595
查看次数

当用户停止移动相机时,Android google maps v2会执行asynctask

我正在制作一个使用谷歌地图api v2的应用程序.我的问题是,当我注册摄像机更改监听器时,每当摄像机移动时,它就会在移动停止时执行.我想实现后者.如何修改我的代码才能在移动停止时注册?

这是我的代码:

mMap.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {
            @Override
            public void onCameraChange(CameraPosition position) {
                LatLngBounds bounds = mMap.getProjection().getVisibleRegion().latLngBounds;
                ne = bounds.northeast;
                sw = bounds.southwest;
                ne1 = ne.latitude;
                ne2 = ne.longitude;
                sw1 = sw.latitude;
                sw2 = sw.longitude;
                new DownloadJSON().execute();
            }
        });
Run Code Online (Sandbox Code Playgroud)

android google-maps android-asynctask

2
推荐指数
1
解决办法
3048
查看次数

在字符串数组android中获取项目位置?

假设我有一个这样的数组:

String[] = {
    "#abc #def",
    "#abc",
    "#def",
    "#xyz #def"
}
Run Code Online (Sandbox Code Playgroud)

我的问题是我想搜索特定的字符或字符串,如"#abc"或"a",并获得他们在数组中的位置.

java arrays string android

1
推荐指数
2
解决办法
1万
查看次数