0
이미지의 높이와 폭입니다.
문제는 이미지의 너비와 높이를 관리 할 수 없다는 것입니다. 내가 XML로 정적 테이블을 만들 때
나는 이미지에 문제가 없었다. 그러나 이제 보시다시피 테이블에있는 세 행을 모두 보여주지는 않습니다. 내가 도대체 뭘 잘못하고있는 겁니까?그리고 내가 원하는 것은 동적 수의 열과 행이있는 테이블입니다. 그리고 나는이 표를 화면에 맞추기를 원합니다.
for (int i = 0; i < im1.length; i++) {
im1[i] = (ImageView) getLayoutInflater().inflate(R.layout.image0, null);
im2[i] = (ImageView) getLayoutInflater().inflate(R.layout.image1, null);
}
table = (TableLayout) getLayoutInflater().inflate(R.layout.table, null);
TableRow row1 = (TableRow) getLayoutInflater().inflate(R.layout.row, null);
row1.addView(im1[0]);
row1.addView(im2[0]);
TableRow row2 = (TableRow) getLayoutInflater().inflate(R.layout.row, null);
row2.addView(im1[1]);
row2.addView(im2[1]);
TableRow row3 = (TableRow) getLayoutInflater().inflate(R.layout.row, null);
row3.addView(im1[2]);
row3.addView(im2[2]);
table.addView(row1);
table.addView(row2);
table.addView(row3);
tableFlipper.addView(table);
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/llayout"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/hello_world"
android:layout_marginTop="10dp" />
<ViewFlipper
android:id="@+id/tableFlipper"
android:layout_width="wrap_content"
android:layout_height="400dp"
android:layout_gravity="center"
android:layout_marginTop="10dp" >
</ViewFlipper>
<Button
android:id="@+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:onClick="onButtonClick" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:shrinkColumns="*" >
</TableLayout>
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
</TableRow>
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/square"
android:scaleType="fitCenter"
android:maxHeight="30dp"
android:maxWidth="30dp" >
,745,