1
私のアプリケーションでの活動は、(1での私の最初の試み)は、それぞれEditTextsのカップルやボタンを含むいくつかのテーブルの行を生成します。しかし、ボタンの位置がずれると、this problemとなり、削除ボタンが少し下に移動します。次のようにアンドロイド:のTableRowでビューを並べてプログラム
XMLレイアウトの要部である:
<ScrollView
android:id="@+id/countEditList"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableLayout
android:id="@+id/countEditLayout"
android:stretchColumns="*"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- insert the new rows here as they are created -->
</TableLayout>
</ScrollView>
データベースカーソルから各行を作成するコードは、次ん
TableRow row = new TableRow(this);
EditText title = new EditText(this);
title.setHorizontallyScrolling(true);
title.setGravity(Gravity.CENTER);
title.setLayoutParams(new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
EditText counting = new EditText(this);
counting.setLayoutParams(new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
counting.setGravity(Gravity.CENTER);
Button deleteCount = new Button(this);
deleteCount.setLayoutParams(new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
deleteCount.setText(R.string.deleteCount);
deleteCount.setOnClickListener(this);
deleteCount.setGravity(Gravity.CENTER);
row.addView(title);
row.addView(counting);
row.addView(deleteCount);
layout.addView(row,new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); // Earlier: layout = (ViewGroup) findViewById(R.id.countEditLayout);
私は何らかの形であるべきであると思われますEditTextsとButtonのlayout_gravityを設定していますが、私はそれを行う方法を考えることができません - 誰でも提案を提供できるでしょうか?
感謝を。残念ながら、行内のdeleteCountボタンの相対的な配置は変更されていないようです。おそらく、テーブルではなく、これに別のレイアウトを使用するべきでしょうか? – knirirr
最後にそれを手に入れました! row.setGravity(Gravity.CENTER);それはトリックを行うように見えます。 – knirirr