小编Rah*_*ran的帖子

如何在回收站视图中为每个项目设置不同的高度

我想在回收站视图中为每个项目设置不同的高度。通常我们每行都得到相同的高度。但是我需要不同的高度,例如,如果前三行的高度为 70,那么我需要其余的高度为 0。我的代码如下。在这段代码中,它没有正确设置。请建议我编辑

public class MainActivity extends AppCompatActivity {

private RecyclerView rvListProfiles;
private ListProfileAdapter listProfileAdapter;
private String[] list = new String[]{"ABC","DEF","GHI","JKL","MNO"};

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    rvListProfiles = findViewById(R.id.rvListProfiles);

    listProfileAdapter = new ListProfileAdapter(list, this);
    RecyclerView.LayoutManager mLayoutManager = new 
    LinearLayoutManager(getApplicationContext());
    rvListProfiles.setLayoutManager(mLayoutManager);
    rvListProfiles.setItemAnimator(new DefaultItemAnimator());
    rvListProfiles.setAdapter(listProfileAdapter);
    String listString = Arrays.toString(list);
    System.out.println("List "+listString);
}
}
Run Code Online (Sandbox Code Playgroud)

项目xml

<?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="70dp"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:background="@android:color/darker_gray"
    android:padding="10dp"
    android:id="@+id/parentLayout">

<ImageView
    android:id="@+id/profileImage"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:layout_alignParentStart="true"
    android:layout_centerVertical="true"
    android:src="@mipmap/love"
    android:transitionName="imageTransition" />

<TextView
    android:id="@+id/profileName"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview

6
推荐指数
1
解决办法
8859
查看次数

从图像 URL 将图标设置为地图中的标记

我想从URL设置一个图标,以在Map中进行标记。我看到了很多解决方案,但所有解决方案都展示了如何从我们的可绘制文件夹中设置图标。在这里,我想要一些不同的东西,我有一个个人资料图像 URL,我需要将该图像设置为我的标记的图标。请建议我解决这个问题。她是我的代码:

private void setUpCurrentMarker(LatLng latLng) {
    mMap.clear();
    if (!isUp)
        onSlideViewButtonClick(addressView);
    //LatLng sydney = new LatLng(-34, 151);
    mMap.addMarker(new MarkerOptions()
            .position(latLng)
            .title("Current Location"));
    mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
    mMap.animateCamera(CameraUpdateFactory.zoomTo(11));
}
Run Code Online (Sandbox Code Playgroud)

android google-maps marker google-maps-markers

0
推荐指数
1
解决办法
1234
查看次数