我正在使用此应用程序,我动态更改ListView大小,如下面的代码所示:
RelativeLayout.LayoutParams mParam = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
sucs.setLayoutParams(myListView);
但是当我这样做时,ListView会出现在视图的顶部。有什么方法可以将它放在文本视图下面吗?
提前致谢!
编辑: 这是我的xml:
<TextView
android:id="@+id/sucursales_empresa"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/direccion_empresa"
android:background="@drawable/barra"
android:text="@string/sucursales"
android:visibility="gone" />
<ListView
android:id="@+id/sucursalesEmpresaList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/sucursales_empresa"
android:cacheColorHint="#00000000"
android:visibility="gone" />
答案 0 :(得分:0)
你必须像这样添加listview LayoutParams规则..
RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params1.addRule(RelativeLayout.BELOW, R.id.textview);
listview.setLayoutParams(params1);
答案 1 :(得分:0)
试试这个
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, view.getId());
view.setLayoutParams(params);
ViewGroup parentView = (ViewGroup) findViewById(R.id.viewgroup);
parentView.addView(mylsitview);