当我尝试创建动态布局宽度时,Android-2列布局看起来一团糟

当我尝试创建动态布局宽度时,Android-2列布局看起来一团糟,android,android-layout,Android,Android Layout,我有这样的布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizo

我有这样的布局:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:orientation="horizontal"
     android:weightSum="1.0">

     <TextView android:id="@+id/TRAIN_CELL"
         android:layout_weight=".8"
         android:layout_height="wrap_content"
         android:layout_width="0dip"        
         android:textSize="16sp"/>

     <TextView android:id="@+id/TO_CELL"
         android:textSize="20sp"
         android:textStyle="bold" 
         android:gravity="center"
         android:textColor="@color/light_best_blue"
         android:layout_height="wrap_content"
         android:layout_width="0dip"  
         android:layout_weight=".2"/>

</LinearLayout>

这是在父屏幕中引用的代码段

<ListView
android:id="@android:id/list"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dp"
    android:text="@+id/label"
    android:textSize="17sp"> 
</ListView> 

我试着在左边有一些文本,在右边有一个>字符,这样用户就可以选择它了

以下是我如何填充列表:

private List<HashMap<String, String>> fillMaps;
private SimpleAdapter adapter;

ListView list = null;       

    list = (ListView) findViewById(android.R.id.list);

    // My data
    fillMaps = new ArrayList<HashMap<String, String>>();

    adapter = new SimpleAdapter(this, fillMaps, R.layout.my_problems,
            new String[] {"train", "to"}, 
            new int[] {R.id.TRAIN_CELL,  R.id.TO_CELL});        

                    for ( int i = 0; i < obj.length(); i++ )
                    {
                        HashMap<String, String> map = new HashMap<String, String>();
                        JSONObject o = obj.getJSONObject(i);                                

                        problem_title = o.getString("problem_title");
                        problem_id = o.getString("problem_id");
                        String has_new_comments = o.getString("has_new_comments");
                        String is_private = o.getString("is_private");

                        Problem p = new Problem ( );
                        p.setProblemId(problem_id);                         
                        p.setProblemName(problem_title);
                        p.setIsPrivate(is_private);
                        p.setHasNewComments(has_new_comments);

                        map.put("train", p.toString() );
                        map.put("to", ">");

                        fillMaps.add(map);
                        problems.add( p );                                                          
                    }

                    adapter.notifyDataSetChanged();                     
私有列表fillMaps;
专用SimpleAdapter适配器;
ListView列表=空;
list=(ListView)findViewById(android.R.id.list);
//我的数据
fillMaps=newarraylist();
adapter=new simpledapter(此、fillMaps、R.layout.my_问题、,
新字符串[]{“train”,“to”},
新int[]{R.id.TRAIN_CELL,R.id.TO_CELL});
对于(int i=0;i”);
fillMaps.add(map);
添加(p);
}
adapter.notifyDataSetChanged();
但是屏幕看起来很乱,左边的列在右边的列旁边,没有空格,“>”字符不是在同一列上排列的,而是根据左边列的结束位置随机隔开的

对可能出现的问题有什么想法吗


谢谢

我从未尝试过使用小于1的权重,所以您可以尝试将所有权重乘以10。否则,请使用层次结构视图查看哪里出了问题。@Commonware您建议权重是多少?我只是不知道使用少于1是不常见的。我需要左栏有大约80%的宽度,右栏有20%“你建议权重是多少?”--8和2。或4和1。或者80和20。比例才是最重要的。我只提到不到一个问题,因为我不记得曾经见过它完成。据我所知,它工作正常。顺便说一句,由于您的两个权重总和达到了您想要的值,我将删除似乎没有任何区别的
weightSum
@commonware:(我刚刚添加了一个两列布局的屏幕截图,以及它的间距如何不正确。