Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如果没有剩余空间,如何自动缩小多个布局?_Android_Android Layout_Android View - Fatal编程技术网

Android 如果没有剩余空间,如何自动缩小多个布局?

Android 如果没有剩余空间,如何自动缩小多个布局?,android,android-layout,android-view,Android,Android Layout,Android View,我想创建一个视图,显示用户可以持有的8个项目。当可用项目少于8个时,项目的imageView将替换为默认图像 用户可以点击项目,他将在布局顶部的文本框中看到每个项目的描述。此编辑文本放置在图像“文本框”的顶部。到目前为止,我注意到有一个选项可以将图像加入到编辑文本中,所以这个问题可能会得到解决 在布局的底部,我希望左侧有一个取消按钮,右侧有一个接受按钮。通过这种方式,用户可以返回游戏,而无需选择项目或选择要使用的项目 问题是,当没有空间以全分辨率绘制图像时,版面会尝试以全分辨率绘制内容。这就是为

我想创建一个视图,显示用户可以持有的8个项目。当可用项目少于8个时,项目的imageView将替换为默认图像

用户可以点击项目,他将在布局顶部的文本框中看到每个项目的描述。此编辑文本放置在图像“文本框”的顶部。到目前为止,我注意到有一个选项可以将图像加入到编辑文本中,所以这个问题可能会得到解决

在布局的底部,我希望左侧有一个取消按钮,右侧有一个接受按钮。通过这种方式,用户可以返回游戏,而无需选择项目或选择要使用的项目

问题是,当没有空间以全分辨率绘制图像时,版面会尝试以全分辨率绘制内容。这就是为什么我的上一行项目是按全尺寸绘制的,而第二行是按比例缩小的

它应该是这样的:

然后我尝试了以下方法:

  • 根布局是线性布局
  • 第一个布局是相对布局,包含imageview和 编辑文本
  • 然后是线性布局(垂直)和垂直布局 另外两个线性布局(水平)
  • 我在每个视图中放置了4个ImageView,表示项目
到目前为止,我没有考虑接受和取消按钮,因为我的结果还是一团糟。



你能帮我设置我想要的视图吗?我迷路了。

你应该使用
TableLayout
GridLayout
来存放你的物品。这种布局可能会让你很沮丧。给你两个建议。设置每个包含版面的背景色,以便您可以轻松看到哪个版面正在做什么。第二个技巧是从一个简单的布局开始,并在学习如何控制每个布局的过程中增加复杂性。因此,在根视图中设置相对布局和两个线性布局的背景色,并删除所有其他内容。正确使用颜色技巧,然后开始重新添加内容。一步一个脚印…BYW,对于这样的布局,我通常从一个相对的布局开始,通过父对齐和下面的布局、布局等来控制一切。祝你好运。
  <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="bottom"
    android:orientation="vertical" >

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <ImageView
            android:id="@+id/textboxview"
            android:layout_width="fill_parent"
            android:layout_height="70dp"
            android:scaleType="fitXY"
            android:src="@drawable/textbox" />

        <com.gootsProject.AutoResizeTextView
            android:id="@+id/dialogText"
            style="@style/monologText"
            android:layout_width="fill_parent"
            android:layout_height="50dp" />
    </RelativeLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <ImageView
                android:id="@+id/ImageView07"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="2dp"
                android:src="@drawable/item_noitem" />

            <ImageView
                android:id="@+id/ImageView05"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="2dp"
                android:src="@drawable/item_noitem" />

            <ImageView
                android:id="@+id/ImageView04"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="2dp"
                android:src="@drawable/item_noitem" />

            <ImageView
                android:id="@+id/ImageView06"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="2dp"
                android:src="@drawable/item_noitem" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <ImageView
                android:id="@+id/ImageView03"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="2dp"
                android:src="@drawable/item_noitem" />

            <ImageView
                android:id="@+id/ImageView02"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="2dp"
                android:src="@drawable/item_noitem" />

            <ImageView
                android:id="@+id/ImageView01"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="2dp"
                android:src="@drawable/item_noitem" />

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="2dp"
                android:src="@drawable/item_noitem" />
        </LinearLayout>
    </LinearLayout>

</LinearLayout>