2016-11-25 19 views
0

我的XML视图是:如何删除listview底部的extraspace?对于layout_through.axml

<?xml version="1.0" encoding="utf-8"?> 
<merge xmlns:android="http://schemas.android.com/apk/res/android"> 
<LinearLayout 
    android:id="@+id/linear_2" 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentLeft="true" 
    android:weightSum="2"> 
    <TextView 
     android:id="@+id/resultsTextView" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:background="@drawable/dual_listview_header_results" 
     android:gravity="center" 
     android:text="Results" 
     android:textStyle="bold" 
     android:textSize="@dimen/PortscustomviewresultsTextViewtextsizeCommon" 
     android:textColor="@color/WhiteText" 
     android:paddingTop="@dimen/PortscustomviewresultsTextViewPaddingTopBottom" 
     android:paddingBottom="@dimen/PortscustomviewresultsTextViewPaddingTopBottom" /> 
    <LinearLayout 
     android:id="@+id/linear_3" 
     android:orientation="vertical" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="1" 
     android:weightSum="2" 
     android:gravity="center" 
     android:background="@drawable/dual_listview_header_numberofframes"> 
     <TextView 
      android:id="@+id/noofframeTextView" 
      android:layout_width="wrap_content" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:layout_marginTop="@dimen/PortscustomviewnoofframeTextViewMarginTop" 
      android:text="Number of Frames" 
      android:textSize="@dimen/PortscustomviewresultsTextViewtextsizeCommon" 
      android:textColor="@color/BlackText" /> 
     <TextView 
      android:id="@+id/noofframeTextView1" 
      android:layout_width="wrap_content" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:layout_marginBottom="@dimen/PortscustomviewnoofframeTextViewMarginTop" 
      android:text="Received of Each Size" 
      android:textSize="@dimen/PortscustomviewresultsTextViewtextsizeCommon" 
      android:textColor="@color/BlackText" /> 
    </LinearLayout> 
</LinearLayout> 
<ListView 
    android:id="@+id/loopbackThroughListView" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_below="@id/linear_2" 
    android:divider="#0188dd00" 
    android:dividerHeight="0dp" 
    android:paddingLeft="@dimen/PortsloopbackThroughListViewPaddingLeftRight" 
    android:paddingRight="@dimen/PortsloopbackThroughListViewPaddingLeftRight" 
    android:background="@color/DarkGrey" /> 
<RelativeLayout 
    android:id="@+id/relative_1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_below="@id/loopbackThroughListView" 
    android:background="@drawable/dual_list_view_footer_next"> 
    <TextView 
     android:id="@+id/oneOfThreeTextView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:text="1 of 3" 
     android:textStyle="bold" 
     android:textSize="@dimen/PortscustomviewresultsTextViewtextsizeCommon" 
     android:textColor="@color/WhiteText" 
     android:paddingBottom="@dimen/PortscustomviewoneOfThreePaddingTopBottom" 
     android:paddingTop="@dimen/PortscustomviewoneOfThreePaddingTopBottom" /> 
    <TextView 
     android:id="@+id/nextTextView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_alignTop="@id/oneOfThreeTextView" 
     android:paddingTop="@dimen/PortscustomviewnextTextViewPaddingTop" 
     android:paddingRight="@dimen/PortscustomviewnextTextViewPaddingRight" 
     android:paddingLeft="@dimen/PortscustomviewnextTextViewPaddingLeft" 
     android:clickable="true" 
     android:text="Next" 
     android:textStyle="bold" 
     android:textSize="@dimen/PortscustomviewresultsTextViewtextsizeCommon" 
     android:textColor="@color/WhiteText" /> 
    <ImageView 
     android:id="@+id/nextImageView" 
     android:src="@drawable/next" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_alignTop="@id/oneOfThreeTextView" 
     android:layout_marginRight="@dimen/PortscustomviewnextImageViewmarginright" 
     android:layout_marginTop="@dimen/PortscustomviewnextImageViewmargintop" /> 
</RelativeLayout> 

由于这种布局是通过LoopbackThroughCustomView.cs类充气母体具有低于的xml:

<Samsung.Ethernet.AndroidDevice.LoopbackThroughCustomView 
    android:id="@+id/loopbackCustomView" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:paddingLeft="@dimen/PortsloopbackCustomViewmarginleft" 
    android:paddingRight="@dimen/PortsloopbackCustomViewmarginright" 
    android:layout_below="@id/loopbackplainTxtView" /> 

而充气代码在LoopbackThroughCustomView.cs类中为: -

Inflate(Context, Resource.Layout.loopback_through, this); 

而对于列表视图中的适配器充气代码如下:

if (view == null) 
     { 
      holder = new LoopbackThroughViewHolder(); 
      view = _activity.LayoutInflater.Inflate(Resource.Layout.loopback_through_listitem, parent, false); 
      holder.result = view.FindViewById<TextView>(Resource.Id.resultTextView); 
      holder.numberofframe = view.FindViewById<TextView>(Resource.Id.numberofframeTextView); 
      holder.wrightWrong = view.FindViewById<ImageView>(Resource.Id.tickCrossImageView); 
      holder.linear1 = view.FindViewById<RelativeLayout>(Resource.Id.linearLayout1); 
      view.Tag = holder; 
     } 

而对于列表项的loopback_through_listitem.axml布局是:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/linearLayout1" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:background="@drawable/loopback_through_listview_background"> 
<View 
    android:id="@+id/lineMiddleTextView" 
    android:layout_width="@dimen/Portscustomviewlinewidth" 
    android:layout_height="@dimen/PortslistitemlineMiddleTextViewheight" 
    android:layout_centerInParent="true" 
    android:background="@color/EasyGUIBtnStartColor" /> 
<TextView 
    android:id="@+id/resultTextView" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerInParent="true" 
    android:layout_toLeftOf="@id/lineMiddleTextView" 
    android:layout_marginRight="@dimen/PortslistitemresultTextViewMarginRight" 
    android:textSize="@dimen/PortsEasyGUIBtnTextSize" 
    android:textColor="@color/BlackText" /> 
<TextView 
    android:id="@+id/numberofframeTextView" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerInParent="true" 
    android:layout_toRightOf="@id/lineMiddleTextView" 
    android:layout_marginLeft="@dimen/PortslistitemresultTextViewMarginRight" 
    android:textSize="@dimen/PortsEasyGUIBtnTextSize" 
    android:textColor="@color/BlackText" /> 
<ImageView 
    android:id="@+id/tickCrossImageView" 
    android:src="@drawable/green_check" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerInParent="true" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="@dimen/PortslistitemresultTextViewMarginRight" /> 

现在的问题是,当我给分频器在loopback_through.axml的列表视图中将高度设置为“0dp”,那么会出现listview底部的一小段额外空间(在列表视图和相对布局之间),当我将divider高度设置为“1dp”时,listview内容占据底部空间,空间被看到,这是t他需要我的解决方案。我想知道为什么在listview中看到的这种行为有任何其他方式通过将相对布局保持在listview下方来将divider高度设置为0dp来占用底部空间,我试图给相对布局设置负marginTop,但这并不是完美的设备。
我想通过将divider高度保持为0dp和相对布局为layout_below listview并且不给出任何顶部边距或底部边距来消除listview中额外的底部空间。谢谢。


回答

0

添加下面的XML代码行:

android:footerDividersEnabled="false" 

它会删除你的列表视图的最后脚注分隔它显示为空白。

快乐编码!

+0

感谢@Anjali回复。该物业没有工作。这个属性是否依赖于任何其他属性? – codemilan

相关问题