下面的xml版本正确处理高度和宽度,而java没有java缺少什么?
xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:orientation="horizontal">
<include android:id="@+id/cell1" layout="@layout/grid_text_view" />
<include android:id="@+id/cell2" layout="@layout/grid_text_view" />
</LinearLayout>
爪哇
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.HORIZONTAL);
ll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
ll.addView((TextView)this.getLayoutInflater().inflate(R.layout.grid_text_view, null));
ll.addView((TextView)this.getLayoutInflater().inflate(R.layout.grid_text_view, null));
setContentView(ll);
grid_text_view
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="0dip"
android:text="1"
android:textSize="20sp"
android:gravity="center"
android:layout_weight="1" />
我已经尝试了 ll.invalidate() 并且它也不起作用?:(
http://www.flickr.com/photos/48409507@N06/sets/72157623618407586/的截图