Having some problems trying to put views in the right places

随声附和 提交于 2019-12-11 09:06:39

问题


I'm generating dynamic tablerows in this 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>

The problem is: I would like to have some views in a specific position using gravity, but when a define for example, button1.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,TableRow.LayoutParams.WRAP_CONTENT,Gravity.CENTER_VERTICAL)); it doesn't work, but if I do this directly in the xml It works(with layout_gravity), someone knows what to do?

来源:https://stackoverflow.com/questions/10373257/having-some-problems-trying-to-put-views-in-the-right-places

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!