【发布时间】:2020-01-14 09:00:18
【问题描述】:
我想匹配所有布局上的图像。
我什么都试过了,这里是代码
<LinearLayout
android:id="@+id/mid_linear_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
...>
<TableLayout
android:id="@+id/tiles_tables"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow
android:id="@+id/row1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3">
<ImageView
android:id="@+id/tile1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
/>
<ImageView
android:id="@+id/tile2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
/>
这里我得到了主要功能:
ImageView[] tiles = new ImageView[9];
for (int i = 0; i <= 8; i++)
{
tiles[i].setImageResource(getResources().getIdentifier("tile_image1","drawable", getPackageName()));
// this is just to get one image for all imageViews
// here stars the problem
tiles[i].getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;
tiles[i].getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
}
我希望图像匹配所有平铺布局。
任何帮助将不胜感激。
【问题讨论】:
-
您想在单行中以相同的高度和宽度(不是静态的,而是根据分辨率)的 3 张图像吗?
-
嗨,谢谢。每行 3 张图像。 9 x 9 瓷砖。相同的宽度和高度。好分辨率..我的意思是有不同的屏幕..所以他们必须伸展。我不知道为什么我得到了它们之间的白色边框......