Java TwoWayView android库如何设置边距(图像之间的间距)?setItemMargin()不工作

Java TwoWayView android库如何设置边距(图像之间的间距)?setItemMargin()不工作,java,android,android-layout,Java,Android,Android Layout,我正在使用库,但无法设置图像之间的边距。我使用了setItemMargin(1),但它不起作用。 当我传递大值(75100)时,它会增加图像之间的间距,但当我尝试将图像设置为彼此非常接近时,比如说2或5,它不起作用。对于低于10的所有值,间距都是相同的默认边距,如下图所示 用于动态添加视图的代码 protected void showTwowayview() { // Get the welcome card layout and add this layout // b

我正在使用库,但无法设置图像之间的边距。我使用了setItemMargin(1),但它不起作用。 当我传递大值(75100)时,它会增加图像之间的间距,但当我尝试将图像设置为彼此非常接近时,比如说2或5,它不起作用。对于低于10的所有值,间距都是相同的默认边距,如下图所示

用于动态添加视图的代码

   protected void showTwowayview() {

    // Get the welcome card layout and add this layout
    // below that.
    adapter = new HorizontalImagesBaseAdapter(MainActivity.this,
            ImageApplication.fromRecorderPaths);
    RelativeLayout myLayout = (RelativeLayout) findViewById(R.id.welcomeCard);
    Log.d("in", "in");
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, 300);
    // Id of the view below which twoway view will be displayed
    params.addRule(RelativeLayout.BELOW, R.id.mannual);
    // set the layout margin
    params.setMargins(LEFT, TOP, RIGHT, BOTTOM);
    myLayout.setLayoutParams(params);
    TwoWayView lparams = (TwoWayView) getLayoutInflater().inflate(
            R.layout.twowayview, myLayout, false);
    TwoWayView twowayview = (TwoWayView) lparams.findViewById(R.id.lvItems);
    myLayout.addView(twowayview, 0);
    //0 is the pisition off the twowayview in the layout
    TwoWayView listView = (TwoWayView) myLayout.getChildAt(0);

    //listView.setItemMargin(1);
    listView.setAdapter(adapter);
}
双向视图

<?xml version="1.0" encoding="utf-8"?>
<org.lucasr.twowayview.TwoWayView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/lvItems"
style="@style/TwoWayView"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false"
android:background="@android:color/holo_green_light"
tools:context=".MainActivity" />

下面的屏幕截图是我得到的最小间距。但我希望图像彼此非常接近。

请注意,像素中的值不是DPI,因此您需要将DPI中的值转换为像素,然后再将其传递给setItemMargin