我的Android应用包含RelativeLayout
,其中包含TableLayout
。
在TableLayout
内,3 ImageView
行中的每一行都有3 TableLayout
秒。 (总共9个)
我遇到的问题是每行中的最后一个ImageView
被部分切断了。
这是我当前的xml代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
tools:context=".Main">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:shrinkColumns="true"
android:id="@+id/TableLayout">
<TableRow
android:id="@+id/TableRow1"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/s1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"/>
<ImageView
android:id="@+id/s2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"/>
<ImageView
android:id="@+id/s3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"/>
</TableRow>
</TableLayout>
</RelativeLayout>
(其余行相同)
我尝试使用fill_parent
和wrap_content
等值,但我还没有取得任何成功。
我想将TableLayout
缩放到屏幕大小,以便在所有设备上看起来都不错,而且不会切断任何图像。
提前致谢!
答案 0 :(得分:0)
您可能希望使用LinearLayout
作为父级,并且TableLayout
内部使用权重,这样您的行和列将通过均匀划分总空间来均匀分布。
如果您希望图片适合分配的空间,请使用match_parent
android:scaleType="fitXY"
ImageViews
TableLayout
内的{{1}}高度和重量。还可以使用其他图像缩放算法,以获得最佳效果(以满足您的需求)尝试使用它,并查看最适合您的内容。