对于我的项目,我希望页面中有 30 张图像,并且我想以一种水平线性布局中有 3 张图像的方式排列它们。
由于我不能使用密度像素,因为它在不同的设备上可能看起来不同,所以我想使用 layout_weights。我们在 XML 文件中的写入方式:
<ImageButton
android:id="@+id/my_image"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center"
**android:layout_weight="0.33"**
android:background="@android:color/transparent"
android:src="@drawable/ic_launcher" />
我想知道Java语言中XML代码的确切等价物是什么。