android - 可疑的尺寸这将使 View 不可见(在子布局中)

标签 android android-layout android-linearlayout android-layout-weight xml-layout

我在 LinearLayout 中有一个子 LinearLayout

内部布局显示一条消息:

尺寸可疑,这将使 View 不可见

我已经设置了布局的方向,父布局是垂直的,内部布局是水平的我还将其中控件的layout_height设置为0dp并设置了权重

不知道为什么?

这是我的 xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <CheckBox
        android:id="@+id/filter_ShowOnlyAvailableItems_Chk"
        android:layout_width="match_parent"
        android:text="@string/Search_ShowOnlyAvailableItems"
        android:layout_height="0dp"
        android:layout_weight="0.3"/>

    <CheckBox
        android:id="@+id/filter_Color_Chk"
        android:layout_width="match_parent"
        android:text="@string/Search_FilterColor"
        android:layout_height="0dp"
        android:layout_weight="0.3"/>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.86">
        <android.support.v7.widget.RecyclerView
            android:id="@+id/filter_colors_recyclerview"
            android:layout_width="match_parent"
            android:background="@color/red"
            android:layout_height="wrap_content">
        </android.support.v7.widget.RecyclerView>
    </ScrollView>

    <LinearLayout
        android:padding="5dp"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.8"/>


        <Button
            android:id="@+id/filter_ok_btn"
            android:text="@string/Filter_Ok"
            android:layout_width="0dp"
            android:textColor="@android:color/black"
            android:layout_weight="0.50"
            android:layout_margin="5dp"
            android:textAlignment="center"
            android:background="@drawable/buttonrounded"
            android:layout_height="wrap_content" />

        <Button
            android:id="@+id/filter_cancel_btn"
            android:text="@string/Filter_Cancel"
            android:layout_width="0dp"
            android:layout_margin="5dp"
            android:textColor="@android:color/black"
            android:layout_weight="0.50"
            android:textAlignment="center"
            android:background="@drawable/buttonrounded"
            android:layout_height="wrap_content" />

    </LinearLayout>
</LinearLayout>

最佳答案

您已在此处关闭线性布局

 <LinearLayout
    android:padding="5dp"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.8"/>

将其更改为

 <LinearLayout
    android:padding="5dp"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.8">

关于android - 可疑的尺寸这将使 View 不可见(在子布局中),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43694370/

相关文章:

android - 为什么观点分布不均

android - LinearLayout 没有设置所需的 layout_height 属性

android - 添加 Pickimage,使用 1 :4 & Replace drawab. 图像裁剪 - 如何?

android - 适用于 Android 的 Phonegap 2.1 - 启动时出现 Hello World App 3 错误

android - 如何在透明模式下在屏幕中央显示3 2 1文字

android - 如何保存android配置布局

安卓布局 : position element below lowest view

android - Qt 不检测 Android NDK

java - Android:如何在某些 Activity 上隐藏 ActionBar

android - LinearLayout 无法正确对齐