我有一个基本的 LinearLayout,里面有 TableLayout 和 ImageView,我想将表格放在顶部,然后将图片放在底部中心,我该如何解决这个问题? 星期四,我在 Java 代码中将所有行添加到 TableLayout 中,因此希望在代码中看到。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="match_parent"
app:showAsAction="ifRoom">
<TableLayout
android:id="@+id/Table"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="1"
android:shrinkColumns="0">
</TableLayout>
<!--<LinearLayout-->
<!--android:layout_gravity="bottom"-->
<!--android:id="@+id/secLayout"-->
<!--android:orientation="vertical"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content">-->
<ImageView
android:id="@+id/pic1"
android:src="@mipmap/pic1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
<!--</LinearLayout>-->
有什么想法吗?
最佳答案
请检查我的解决方案
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="match_parent"
app:showAsAction="ifRoom" // remove it
>
<TableLayout
android:id="@+id/Table"
android:layout_width="match_parent"
android:layout_height="0dp" // change it
android:layout_weight = 1 // add it
android:stretchColumns="1"
android:shrinkColumns="0">
</TableLayout>
<ImageView
android:id="@+id/pic1"
android:src="@mipmap/pic1"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
</LinearLayout>
希望这有帮助
关于Android 将TableLayout 和LinearLayout 一起添加?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32837466/