假设我有一个tablerow,并且在那个tablerow里面有3个元素(ImageViews)。Android元素固定位置
在第一种情况下,所有3个项目都具有可见性值VISIBLE。假设正在将元素的可见性设置为GONE。那么在这种情况下,其他两件物品会被调整到错过一次的地方。
但我想要的是我需要成为一个固定位置的所有项目。因此,如果我将任何项目的可见性都设为GONE状态,那么在这种情况下,其余元素也会处于同一个位置。
任何人都可以帮助我做到这一点。
假设我有一个tablerow,并且在那个tablerow里面有3个元素(ImageViews)。Android元素固定位置
在第一种情况下,所有3个项目都具有可见性值VISIBLE。假设正在将元素的可见性设置为GONE。那么在这种情况下,其他两件物品会被调整到错过一次的地方。
但我想要的是我需要成为一个固定位置的所有项目。因此,如果我将任何项目的可见性都设为GONE状态,那么在这种情况下,其余元素也会处于同一个位置。
任何人都可以帮助我做到这一点。
使用stretchcolumns
布局,并在每ImageView
指定layout_span
和layout_column
..
Try this out,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="1" >
<TableRow
android:id="@+id/button"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/topbg" >
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_span="1"
android:src="@drawable/ic_add" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_span="1"
android:src="@drawable/ic_add" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="2"
android:layout_span="1"
android:src="@drawable/ic_add" />
</TableRow>
</TableLayout>
</LinearLayout>
我想你没有明白我的意思。在这种情况下,同样的事情也会发生。 – 2012-02-16 14:46:16
如果你想要更多的灵活性,您的项目总是试图去相对布局,希望你能轻松解决您的问题通过使用相对布局。你可以动态地或静态地对物品做任何你想做的事情。
你可以更具体..或你可以只提供任何有用的链接。 – 2012-02-16 11:33:50