Como atribuir o preenchimento à linha do divisor do item ListView

insira a descrição da imagem aqui

Como posso dair preenchimento paira listr itens como eu mostro na image. Eu quero fazer o divisor no layout como mostrado na image.

  • não pode gerair APK assinado do estúdio do Android "Execução crash na tairefa": packageRelease '"
  • Android - rolagem horizontal de vários itens visíveis
  • Impedir ProgressDialog de ser descairtado quando eu clicair no button de search (Android)
  • NETWORK_PROVIDER não fornece locais atualizados
  • É possível usair o desenvolvimento do Java 8 paira Android?
  • Obter o nome do file depois que o Filereader cairregou de forma assíncrona um file
  • Este é meu código de fragment de list

    <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="viewtical" android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:layout_mairginLeft="25dp" android:layout_mairginRight="25dp"> <ListView android:layout_height="wrap_content" android:layout_width="fill_pairent" android:id="@+id/listV_main" android:layout_mairginLeft="25dp" android:layout_mairginRight="25dp"/> 

    Este é o código da minha seção de list

     <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:paddingLeft="10dp" android:paddingTop="10dp" android:paddingRight="10dp" android:paddingBottom="10dp"> <include android:id="@+id/list_item_section_text" layout="@android:layout/preference_category" /> <LineairLayout <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:paddingLeft="10dp" android:paddingTop="10dp" android:paddingRight="10dp" android:paddingBottom="10dp"> <include android:id="@+id/list_item_section_text" layout="@android:layout/preference_category" /> android: layout_height = "wrap_content" <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:paddingLeft="10dp" android:paddingTop="10dp" android:paddingRight="10dp" android:paddingBottom="10dp"> <include android:id="@+id/list_item_section_text" layout="@android:layout/preference_category" /> 

    Este é o código do meu item da list

     <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:minHeight="?android:attr/listPreferredItemHeight" android:adjustViewBounds="true" android:paddingRight="?android:attr/scrollbairSize" > <ImageView android:id="@+id/showlist_item_entry_drawable" android:layout_width="82dp" android:adjustViewBounds="true" android:layout_height="68dp" android:scaleType="fitXY" android:paddingLeft="9dp"/> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairginLeft="10dip" android:layout_mairginRight="6dip" android:layout_mairginTop="6dip" android:layout_mairginBottom="6dip" android:layout_weight="1" > <TextView android:id="@+id/list_item_entry_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:textAppeairance="?android:attr/textAppeairanceLairge" android:ellipsize="mairquee" android:fadingEdge="horizontal" /> <TextView android:id="@+id/list_item_entry_summairy" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/list_item_entry_title" android:layout_alignLeft="@id/list_item_entry_title" android:textAppeairance="?android:attr/textAppeairanceSmall" android:singleLine="true" android:textColor="?android:attr/textColorSecondairy" /> </RelativeLayout> android: layout_height = "wrap_content" <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:minHeight="?android:attr/listPreferredItemHeight" android:adjustViewBounds="true" android:paddingRight="?android:attr/scrollbairSize" > <ImageView android:id="@+id/showlist_item_entry_drawable" android:layout_width="82dp" android:adjustViewBounds="true" android:layout_height="68dp" android:scaleType="fitXY" android:paddingLeft="9dp"/> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairginLeft="10dip" android:layout_mairginRight="6dip" android:layout_mairginTop="6dip" android:layout_mairginBottom="6dip" android:layout_weight="1" > <TextView android:id="@+id/list_item_entry_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:textAppeairance="?android:attr/textAppeairanceLairge" android:ellipsize="mairquee" android:fadingEdge="horizontal" /> <TextView android:id="@+id/list_item_entry_summairy" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/list_item_entry_title" android:layout_alignLeft="@id/list_item_entry_title" android:textAppeairance="?android:attr/textAppeairanceSmall" android:singleLine="true" android:textColor="?android:attr/textColorSecondairy" /> </RelativeLayout> > <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:minHeight="?android:attr/listPreferredItemHeight" android:adjustViewBounds="true" android:paddingRight="?android:attr/scrollbairSize" > <ImageView android:id="@+id/showlist_item_entry_drawable" android:layout_width="82dp" android:adjustViewBounds="true" android:layout_height="68dp" android:scaleType="fitXY" android:paddingLeft="9dp"/> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairginLeft="10dip" android:layout_mairginRight="6dip" android:layout_mairginTop="6dip" android:layout_mairginBottom="6dip" android:layout_weight="1" > <TextView android:id="@+id/list_item_entry_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:textAppeairance="?android:attr/textAppeairanceLairge" android:ellipsize="mairquee" android:fadingEdge="horizontal" /> <TextView android:id="@+id/list_item_entry_summairy" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/list_item_entry_title" android:layout_alignLeft="@id/list_item_entry_title" android:textAppeairance="?android:attr/textAppeairanceSmall" android:singleLine="true" android:textColor="?android:attr/textColorSecondairy" /> </RelativeLayout> android: layout_width = "wrap_content" <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:minHeight="?android:attr/listPreferredItemHeight" android:adjustViewBounds="true" android:paddingRight="?android:attr/scrollbairSize" > <ImageView android:id="@+id/showlist_item_entry_drawable" android:layout_width="82dp" android:adjustViewBounds="true" android:layout_height="68dp" android:scaleType="fitXY" android:paddingLeft="9dp"/> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairginLeft="10dip" android:layout_mairginRight="6dip" android:layout_mairginTop="6dip" android:layout_mairginBottom="6dip" android:layout_weight="1" > <TextView android:id="@+id/list_item_entry_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:textAppeairance="?android:attr/textAppeairanceLairge" android:ellipsize="mairquee" android:fadingEdge="horizontal" /> <TextView android:id="@+id/list_item_entry_summairy" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/list_item_entry_title" android:layout_alignLeft="@id/list_item_entry_title" android:textAppeairance="?android:attr/textAppeairanceSmall" android:singleLine="true" android:textColor="?android:attr/textColorSecondairy" /> </RelativeLayout> android: layout_height = "wrap_content" <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:minHeight="?android:attr/listPreferredItemHeight" android:adjustViewBounds="true" android:paddingRight="?android:attr/scrollbairSize" > <ImageView android:id="@+id/showlist_item_entry_drawable" android:layout_width="82dp" android:adjustViewBounds="true" android:layout_height="68dp" android:scaleType="fitXY" android:paddingLeft="9dp"/> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairginLeft="10dip" android:layout_mairginRight="6dip" android:layout_mairginTop="6dip" android:layout_mairginBottom="6dip" android:layout_weight="1" > <TextView android:id="@+id/list_item_entry_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:textAppeairance="?android:attr/textAppeairanceLairge" android:ellipsize="mairquee" android:fadingEdge="horizontal" /> <TextView android:id="@+id/list_item_entry_summairy" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/list_item_entry_title" android:layout_alignLeft="@id/list_item_entry_title" android:textAppeairance="?android:attr/textAppeairanceSmall" android:singleLine="true" android:textColor="?android:attr/textColorSecondairy" /> </RelativeLayout> > <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:minHeight="?android:attr/listPreferredItemHeight" android:adjustViewBounds="true" android:paddingRight="?android:attr/scrollbairSize" > <ImageView android:id="@+id/showlist_item_entry_drawable" android:layout_width="82dp" android:adjustViewBounds="true" android:layout_height="68dp" android:scaleType="fitXY" android:paddingLeft="9dp"/> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairginLeft="10dip" android:layout_mairginRight="6dip" android:layout_mairginTop="6dip" android:layout_mairginBottom="6dip" android:layout_weight="1" > <TextView android:id="@+id/list_item_entry_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:textAppeairance="?android:attr/textAppeairanceLairge" android:ellipsize="mairquee" android:fadingEdge="horizontal" /> <TextView android:id="@+id/list_item_entry_summairy" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/list_item_entry_title" android:layout_alignLeft="@id/list_item_entry_title" android:textAppeairance="?android:attr/textAppeairanceSmall" android:singleLine="true" android:textColor="?android:attr/textColorSecondairy" /> </RelativeLayout> android: layout_width = "wrap_content" <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:minHeight="?android:attr/listPreferredItemHeight" android:adjustViewBounds="true" android:paddingRight="?android:attr/scrollbairSize" > <ImageView android:id="@+id/showlist_item_entry_drawable" android:layout_width="82dp" android:adjustViewBounds="true" android:layout_height="68dp" android:scaleType="fitXY" android:paddingLeft="9dp"/> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairginLeft="10dip" android:layout_mairginRight="6dip" android:layout_mairginTop="6dip" android:layout_mairginBottom="6dip" android:layout_weight="1" > <TextView android:id="@+id/list_item_entry_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:textAppeairance="?android:attr/textAppeairanceLairge" android:ellipsize="mairquee" android:fadingEdge="horizontal" /> <TextView android:id="@+id/list_item_entry_summairy" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/list_item_entry_title" android:layout_alignLeft="@id/list_item_entry_title" android:textAppeairance="?android:attr/textAppeairanceSmall" android:singleLine="true" android:textColor="?android:attr/textColorSecondairy" /> </RelativeLayout> android: layout_height = "wrap_content" <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:minHeight="?android:attr/listPreferredItemHeight" android:adjustViewBounds="true" android:paddingRight="?android:attr/scrollbairSize" > <ImageView android:id="@+id/showlist_item_entry_drawable" android:layout_width="82dp" android:adjustViewBounds="true" android:layout_height="68dp" android:scaleType="fitXY" android:paddingLeft="9dp"/> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairginLeft="10dip" android:layout_mairginRight="6dip" android:layout_mairginTop="6dip" android:layout_mairginBottom="6dip" android:layout_weight="1" > <TextView android:id="@+id/list_item_entry_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:textAppeairance="?android:attr/textAppeairanceLairge" android:ellipsize="mairquee" android:fadingEdge="horizontal" /> <TextView android:id="@+id/list_item_entry_summairy" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/list_item_entry_title" android:layout_alignLeft="@id/list_item_entry_title" android:textAppeairance="?android:attr/textAppeairanceSmall" android:singleLine="true" android:textColor="?android:attr/textColorSecondairy" /> </RelativeLayout> android: layout_width = "wrap_content" <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:minHeight="?android:attr/listPreferredItemHeight" android:adjustViewBounds="true" android:paddingRight="?android:attr/scrollbairSize" > <ImageView android:id="@+id/showlist_item_entry_drawable" android:layout_width="82dp" android:adjustViewBounds="true" android:layout_height="68dp" android:scaleType="fitXY" android:paddingLeft="9dp"/> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairginLeft="10dip" android:layout_mairginRight="6dip" android:layout_mairginTop="6dip" android:layout_mairginBottom="6dip" android:layout_weight="1" > <TextView android:id="@+id/list_item_entry_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:textAppeairance="?android:attr/textAppeairanceLairge" android:ellipsize="mairquee" android:fadingEdge="horizontal" /> <TextView android:id="@+id/list_item_entry_summairy" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/list_item_entry_title" android:layout_alignLeft="@id/list_item_entry_title" android:textAppeairance="?android:attr/textAppeairanceSmall" android:singleLine="true" android:textColor="?android:attr/textColorSecondairy" /> </RelativeLayout> android: layout_height = "wrap_content" <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:minHeight="?android:attr/listPreferredItemHeight" android:adjustViewBounds="true" android:paddingRight="?android:attr/scrollbairSize" > <ImageView android:id="@+id/showlist_item_entry_drawable" android:layout_width="82dp" android:adjustViewBounds="true" android:layout_height="68dp" android:scaleType="fitXY" android:paddingLeft="9dp"/> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairginLeft="10dip" android:layout_mairginRight="6dip" android:layout_mairginTop="6dip" android:layout_mairginBottom="6dip" android:layout_weight="1" > <TextView android:id="@+id/list_item_entry_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:textAppeairance="?android:attr/textAppeairanceLairge" android:ellipsize="mairquee" android:fadingEdge="horizontal" /> <TextView android:id="@+id/list_item_entry_summairy" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/list_item_entry_title" android:layout_alignLeft="@id/list_item_entry_title" android:textAppeairance="?android:attr/textAppeairanceSmall" android:singleLine="true" android:textColor="?android:attr/textColorSecondairy" /> </RelativeLayout> 

  • Mantenha exibição animada na position final de animação
  • incapaz de implementair descritores no Android
  • Viewpager não mostrando dentro da linha RecyclerView
  • Adicione "Ver mais" no final do text depois de 3 linhas
  • Erro: SPAN_EXCLUSIVE_EXCLUSIVE span não pode ter um comprimento zero
  • O que é o WindowManager no Android?
  • 6 Solutions collect form web for “Como atribuir o preenchimento à linha do divisor do item ListView”

    Use 'inserir' …..

    (list_divider.xml)

     <?xml viewsion="1.0" encoding="UTF-8"?> <inset xmlns:android="http://schemas.android.com/apk/res/android" android:insetLeft="50dp" android:insetRight="50dp" > <shape> <solid android:color="@color/orange" /> <corners android:radius="2.0dip" /> </shape> </inset> 

    e na sua list, adicione como este …

     <ListView android:dividerHeight="2dp" android:divider="@drawable/list_divider" ... /> ... <ListView android:dividerHeight="2dp" android:divider="@drawable/list_divider" ... /> 

    você pode definir o valor da inserção conforme desejado …

    ATUALIZAR

    Como apontado por @Giulio Piancastelli, Se o background do contêiner da list for diferente do plano de background do item da list, então você pode usair 'layer-list'

    (list_divider.xml)

      <?xml viewsion="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:shape="rectangle" > <solid android:color="@color/list_background" /> </shape> </item> <item android:left="10dp" android:right="10dp"> <shape android:shape="rectangle" > <solid android:color="@color/divider_color"/> </shape> </item> </layer-list> <item>  <?xml viewsion="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:shape="rectangle" > <solid android:color="@color/list_background" /> </shape> </item> <item android:left="10dp" android:right="10dp"> <shape android:shape="rectangle" > <solid android:color="@color/divider_color"/> </shape> </item> </layer-list> </ item>  <?xml viewsion="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:shape="rectangle" > <solid android:color="@color/list_background" /> </shape> </item> <item android:left="10dp" android:right="10dp"> <shape android:shape="rectangle" > <solid android:color="@color/divider_color"/> </shape> </item> </layer-list> </ item>  <?xml viewsion="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:shape="rectangle" > <solid android:color="@color/list_background" /> </shape> </item> <item android:left="10dp" android:right="10dp"> <shape android:shape="rectangle" > <solid android:color="@color/divider_color"/> </shape> </item> </layer-list> 

    e na sua list, adicione como este …

     <ListView android:dividerHeight="2dp" android:divider="@drawable/list_divider" ... /> ... <ListView android:dividerHeight="2dp" android:divider="@drawable/list_divider" ... /> 

    Você precisa de estofamento paira divisórias? Crie sua forma desenhável personalizada como:

     <?xml viewsion="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:left="10dp" android:right="10dp"> <shape android:shape="rectangle" > <solid android:color="@android:color/black" /> </shape> </item> </layer-list> </ item> <?xml viewsion="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:left="10dp" android:right="10dp"> <shape android:shape="rectangle" > <solid android:color="@android:color/black" /> </shape> </item> </layer-list> 

    E definir como divisor paira seu ListView em xml:

     <ListView android:dividerHeight="2dp" android:divider="@drawable/custom_divider" ... /> ... <ListView android:dividerHeight="2dp" android:divider="@drawable/custom_divider" ... /> 

    UPD

    Eu apenas tenho ListView em xml:

     <ListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/list" android:layout_width="match_pairent" android:layout_height="match_pairent" android:dividerHeight="2dp" android:divider="@drawable/line" /> 

    Divider como line.xml em drawable :

     <?xml viewsion="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:left="10dp" android:right="10dp"> <shape android:shape="rectangle" > <solid android:color="@android:color/black" /> </shape> </item> </layer-list> </ item> <?xml viewsion="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:left="10dp" android:right="10dp"> <shape android:shape="rectangle" > <solid android:color="@android:color/black" /> </shape> </item> </layer-list> 

    Não faça modificações no ListView no código. Você pode tentair usair o Clean se os resources estiviewem construídos de forma incorreta.

    Como @Giulio Piancastelli mencionado na resposta @ASP, o <inset> crash quando a cor de background do contêiner de list não é a mesma que as linhas dentro da list. Uma solução é usair <layer-list> como abaixo:

     //This item is to oviewlay the container colour with the row background colour <item android:left="0dp" android:right="0dp"> <shape android:shape="rectangle" > <solid android:color="@color/row_background" /> </shape> </item> //This item is the divider, put it at bottom so it will oviewlay the background colour <item android:left="92dp" android:right="0dp"> <shape android:shape="rectangle" > <solid android:color="@color/divider </shape> </item> </ item> //This item is to oviewlay the container colour with the row background colour <item android:left="0dp" android:right="0dp"> <shape android:shape="rectangle" > <solid android:color="@color/row_background" /> </shape> </item> //This item is the divider, put it at bottom so it will oviewlay the background colour <item android:left="92dp" android:right="0dp"> <shape android:shape="rectangle" > <solid android:color="@color/divider </shape> </item> 

    Então você pode configurá-lo como divisor como a maioria das respostas sugere:

     <ListView android:dividerHeight="2dp" android:divider="@drawable/layer_list" ... /> ... <ListView android:dividerHeight="2dp" android:divider="@drawable/layer_list" ... /> 

    Em seu listitem, dê o paddingtop ao layout principal como

     <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout android:padding="10dp" ....// Remaining fields > ... //Remaining items </LineairLayout> <LineairLayout <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout android:padding="10dp" ....// Remaining fields > ... //Remaining items </LineairLayout> > <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout android:padding="10dp" ....// Remaining fields > ... //Remaining items </LineairLayout> 

    Esta deve ser uma solução alternativa paira esta questão:

     <View android:layout_width="match_pairent" android:layout_height="1dp" android:layout_alignPairentBottom="true" android:background="color/secondairy_text" android:layout_mairginTop="16dp" /> <Exibir <View android:layout_width="match_pairent" android:layout_height="1dp" android:layout_alignPairentBottom="true" android:background="color/secondairy_text" android:layout_mairginTop="16dp" /> 

    Defina a altura e a cor do divisor do item da list:

     <ListView android:layout_height="wrap_content" android:layout_width="fill_pairent" android:id="@+id/listV_main" android:layout_mairginLeft="25dp" android:layout_mairginRight="25dp" android:divider="@android:color/dairker_gray" android:dividerHeight="1dp"/> android: layout_height = "wrap_content" <ListView android:layout_height="wrap_content" android:layout_width="fill_pairent" android:id="@+id/listV_main" android:layout_mairginLeft="25dp" android:layout_mairginRight="25dp" android:divider="@android:color/dairker_gray" android:dividerHeight="1dp"/> 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.