Java 线性布局中的项目不适合屏幕
我使用线性布局来显示相对布局内的图像视图。我希望图像视图水平地占据屏幕的整个宽度,所有屏幕类型之间没有空格。 但是,视图之间仍然存在不需要的空间。我需要帮助Java 线性布局中的项目不适合屏幕,java,android,Java,Android,我使用线性布局来显示相对布局内的图像视图。我希望图像视图水平地占据屏幕的整个宽度,所有屏幕类型之间没有空格。 但是,视图之间仍然存在不需要的空间。我需要帮助 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/
<?xml version="1.0" encoding="utf-8"?>
<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="match_parent"
android:background="@drawable/back_main"
tools:context="com.example.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1"
android:layout_alignParentBottom="true">
<ImageView
android:layout_width="wrap_content"
android:layout_height="56dp"
android:layout_weight="0.25"
android:src="@drawable/img_audio"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="56dp"
android:layout_weight="0.25"
android:src="@drawable/img_event"/>
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="56dp"
android:layout_weight="0.25"
android:src="@drawable/img_video" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="56dp"
android:layout_weight="0.25"
android:src="@drawable/img_more"/>
</LinearLayout>
</RelativeLayout>
用法:android:scaleType=fitXY
将imageview的代码替换为
也许下面的布局就是我根据你的问题修改代码的方法。根据您的需要进行修改
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/back_main"
tools:context="com.example.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<ImageView
android:layout_width="0dp"
android:layout_height="56dp"
android:layout_weight="1"
android:src="@drawable/foo" />
<ImageView
android:layout_width="0dp"
android:layout_height="56dp"
android:layout_weight="1"
android:src="@drawable/bar"/>
<ImageView
android:layout_width="0dp"
android:layout_height="56dp"
android:layout_weight="1"
android:src="@drawable/foobar"/>
</LinearLayout>
根据你使用的图像,在IVIEVIEWS中考虑使用Android:SimeType。< /P>你想将图像按屏幕的水平顺序放置吗?是的。但它并没有填满不该填满的宽度,因为它对应于图像的大小和屏幕宽度。也许您可以通过编程方式获得屏幕宽度,并根据图像数量进行划分,以将结果设置为图像宽度硬编码。在ImageView中使用android:adjustViewBounds=true。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/back_main"
tools:context="com.example.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<ImageView
android:layout_width="0dp"
android:layout_height="56dp"
android:layout_weight="1"
android:src="@drawable/foo" />
<ImageView
android:layout_width="0dp"
android:layout_height="56dp"
android:layout_weight="1"
android:src="@drawable/bar"/>
<ImageView
android:layout_width="0dp"
android:layout_height="56dp"
android:layout_weight="1"
android:src="@drawable/foobar"/>
</LinearLayout>