android 布局位图没有填满 space
android lay-out bitmap doesn't take full space
我有一个要显示的位图,但是它并没有占据它所有的位置。我尝试了不同类型的布局(线性、相对、绝对、约束等),但其中 none 有效。我还尝试将宽度和高度设置为 'match_parent'。它看起来像 this(右边的图像应该和左边的图像一样多 space)。
这是我的 XML-文件:
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<io.fotoapparat.view.CameraView
android:id="@+id/cameraView"
android:layout_width="193dp"
android:layout_height="256dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />
<android.support.v7.widget.AppCompatImageView
android:id="@+id/imageView"
android:layout_width="193dp"
android:layout_height="256dp"
android:layout_alignParentStart="false"
android:layout_alignParentTop="false"
android:layout_column="1"
android:layout_row="0"
android:adjustViewBounds="false"
android:rotation="90" />
</GridLayout>
这就是我解决问题的方法,我只需要删除 android:rotate="90"
并在程序本身中旋转位图。
为什么要修复 height
和 width
?
您可以使用 LinearLayout
和 2 个视图,给出 android:layout_width=0dp
和 android:layout_weight=1
一定会成功的。
我有一个要显示的位图,但是它并没有占据它所有的位置。我尝试了不同类型的布局(线性、相对、绝对、约束等),但其中 none 有效。我还尝试将宽度和高度设置为 'match_parent'。它看起来像 this(右边的图像应该和左边的图像一样多 space)。 这是我的 XML-文件:
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<io.fotoapparat.view.CameraView
android:id="@+id/cameraView"
android:layout_width="193dp"
android:layout_height="256dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />
<android.support.v7.widget.AppCompatImageView
android:id="@+id/imageView"
android:layout_width="193dp"
android:layout_height="256dp"
android:layout_alignParentStart="false"
android:layout_alignParentTop="false"
android:layout_column="1"
android:layout_row="0"
android:adjustViewBounds="false"
android:rotation="90" />
</GridLayout>
这就是我解决问题的方法,我只需要删除 android:rotate="90"
并在程序本身中旋转位图。
为什么要修复 height
和 width
?
您可以使用 LinearLayout
和 2 个视图,给出 android:layout_width=0dp
和 android:layout_weight=1
一定会成功的。