Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separator padding , ignoring it

I have a problem with this separator:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
    <padding android:left="10dip" android:right="10dip"/>
    <solid android:color="@color/listSeparator"/>
    <size android:height="1px" />
</shape>

I'm trying to make a little margin/padding in the left/right of the listview component (using a relative on it , not a ListView Object) . Then when i try to put it this way...

getListView().setDivider(getResources().getDrawable(R.drawable.song_separator));

... it's directly ignored , putting a full layout separator .

Now i don't know what is the problem , but i know that :

  • I can't put a margin in all ListView , cause i want the listHeader fill_parent
  • I have tried to put a false border , but it isn't nice looking when i change it's background color , putting me a separator space.

Any idea?

MODIFIED

My last partial solution is to put an ImageView , aligned next to the parent bottom . This is partial cause it puts on the bottom but not on the original divider.

If someone can tell me how to put that ImageView on the exact line of the divider, i would give him the +50 too.

like image 906
A.Quiroga Avatar asked Oct 18 '11 12:10

A.Quiroga


1 Answers

Quiroga so my first bet would be to make the code more debugable by spliting the method call up into individual lines.

ListView lview = getListView();
if (lview != null){
  Resources res = getResources();
  if (res != null) {
       Drawable dable = res.getDrawable(R.drawable.song_separator);
       if (dable != null){
           lview.setDivider(dable)
       }
  }
} else {
   //Log in some way that you have a problem.
}

I know it looks kind of over complicated but that way you can make sure that the Drawable is found and is the correct one and then properly assigned to the ListView.

Another thing you can try is just assigning a different maybe platform specific separator and see if that works properly.

Also try to get your hands on the Android Source Code it is back online if you add that to your Java Project you can debug into the Platform classes and debug deep into the platform code.

So this isn't really a solution for your problem but maybe it can help you find the solution.

like image 90
AGrunewald Avatar answered Oct 20 '22 04:10

AGrunewald