Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.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_User Interface_Layout_Attributes_Css - Fatal编程技术网

Android用户界面:什么样的布局选项是相互排斥的?

Android用户界面:什么样的布局选项是相互排斥的?,android,user-interface,layout,attributes,css,Android,User Interface,Layout,Attributes,Css,在安卓系统中设计了一段时间的布局之后,我仍然无法掌握它的窍门。结果往往是不可预测的 我认为这部分归结为一些布局选项不能很好地协同工作。也就是说,如果您使用的是一种指定布局的方式,那么就不需要使用其他方式 值得注意的是,对我来说,将layout\u width从fill\u parent更改为wrap\u content通常会改变世界。让我再举一个具体的例子: 我的活动布局的一部分是线性布局: <LinearLayout android:id="@+id/ll2" android:l

在安卓系统中设计了一段时间的布局之后,我仍然无法掌握它的窍门。结果往往是不可预测的

我认为这部分归结为一些布局选项不能很好地协同工作。也就是说,如果您使用的是一种指定布局的方式,那么就不需要使用其他方式

值得注意的是,对我来说,将
layout\u width
fill\u parent
更改为
wrap\u content
通常会改变世界。让我再举一个具体的例子:

我的活动布局的一部分是线性布局:

    <LinearLayout android:id="@+id/ll2" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:orientation="horizontal">
        <LinearLayout android:id="@+id/ll2a" android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:orientation="vertical" android:layout_weight="1">
            <TextView android:id="@+id/l_cover" android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:text="@string/book_item_l_cover">
            </TextView>
            <ImageButton android:id="@+id/i_cover"
                android:layout_width="wrap_content" android:layout_height="wrap_content"
                android:scaleType="centerInside" android:gravity="center"
                android:layout_weight="1" android:adjustViewBounds="true"
                android:src="@drawable/spinner_black_76" android:minWidth="400dip">
            </ImageButton>
        </LinearLayout>
        <LinearLayout android:id="@+id/ll2b" android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:orientation="vertical" android:layout_weight="1">
            <TextView android:id="@+id/l_back_cover" android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:text="@string/book_item_l_back_cover">
            </TextView>
            <ImageButton android:id="@+id/i_back_cover"
                android:layout_width="wrap_content" android:layout_height="wrap_content"
                android:scaleType="centerInside" android:gravity="center"
                android:layout_weight="1" android:adjustViewBounds="true"
                android:src="@drawable/spinner_black_76">
            </ImageButton>
        </LinearLayout>
    </LinearLayout>

为了得到相邻的两列左对齐标签按钮组合,我必须使用
layout\u weight
属性。由于
adjustViewBounds
属性,图像按钮在其图像周围收缩。这给了我一个很好的结果

现在我最后想要的是有一个最小尺寸的按钮,这样手指就可以轻松地按下它们,即使它们不包含任何图像(并且它们会缩小到只有几毫米)。如您所见,我尝试了设置android:minWidth=“400dip”。我希望按钮的宽度能填满整个屏幕的一半(400是一个相当大的值),但我没有看到任何区别


我猜上面的另一个属性是防止
minWidth
产生任何影响。我可能会去做个实验,让其他人失去能力,看看它给了我什么。但我这里的问题是:有人有任何(逻辑)信息,关于哪个属性阻止或反直觉地影响哪个属性吗?我想一劳永逸地对其进行排序。这在什么地方有记录吗?

我注意到布局权重似乎使minWidth变得无用

给定线性布局中的三个按钮,左、右的权重为0,中心为1,更改其中任何一个按钮的最小宽度绝对不会影响视图的渲染方式,直到我完全删除每个按钮的布局权重属性。我甚至确保所有最小宽度的总和小于总视图的宽度

我不知道为什么会这样。关于布局重量:

此属性指定“重要性” 值,并允许它 展开以填充中的所有剩余空间 父视图。子视图可以 指定整数权重值,然后 然后查看视图中的任何剩余空间 组被分配给组中的子级 声明重量的比例


我也很想知道其他布局参数之间有什么冲突。定义视图的权重以填充“父视图中的剩余空间”将完全忽略视图的最小宽度设置,这对我来说似乎非常不直观。

谢谢。和你一样,我希望得到更多的答案。我要让这个门再开一会儿。