1

この XML で動的テーブル行を生成しています

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:scrollbars="none" >

    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/layoutPrincipal1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        android:stretchColumns="1">

    </TableLayout>

</ScrollView>

問題は次のとおりです。重力を使用して特定の位置にいくつかのビューを配置したいのですが、たとえば、button1.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,TableRow.LayoutParams.WRAP_CONTENT,Gravity.CENTER_VERTICAL) を定義すると、 ); それは機能しませんが、xml で直接これを行うと (layout_gravity を使用して) 機能します。誰かが何をすべきか知っていますか?

4

0 に答える 0