Android-按屏幕大小缩放表格布局
我有一个Android应用程序,它包含一个Android-按屏幕大小缩放表格布局,android,xml,Android,Xml,我有一个Android应用程序,它包含一个RelativeLayout,里面有一个TableLayout 在TableLayout中,3行TableLayout中的每一行都有3个ImageViews。(共9个) 我遇到的问题是,每行的最后一个ImageView部分被切断 这是我当前的xml代码: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http:/
RelativeLayout
,里面有一个TableLayout
在TableLayout
中,3行TableLayout
中的每一行都有3个ImageView
s。(共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\u parent
和wrap\u content
等值,但还没有成功
我想将TableLayout
缩放到屏幕的大小,这样它在所有设备上看起来都很好,而不会切断任何图像
以下是一个屏幕截图:
提前谢谢 您可能希望使用
LinearLayout
作为父级,并让TableLayout
在内部使用权重,这样,您的行和列将通过平均分配总可用空间来均匀分布
此外,如果您希望图像适合分配的空间,请在
表格布局内的图像视图中使用match\u parent
与android:scaleType=“fitXY”
匹配身高和体重。其他图像缩放算法也可用,因此为了获得最佳效果(满足您的需要),请尝试使用它,看看什么最适合您 它是从右边切的还是从下面切的?你可以添加一个截图吗?@RobinF图片在右边被剪切。我将尝试获取一个屏幕截图。@RobinF我添加了一个屏幕截图,希望它能有所帮助。使用LinearLayout
并使用scaleType=“fitXY”
缩放图像时运气不佳。还有其他建议吗?除了将android:stretchColumns=“*”添加到tablelayout并尝试使用不同的缩放算法之外,这些算法建议作为ImageView=>android:scaleType属性的自动完成。要了解更多关于它们的信息,您可以在此处查看-