Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.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 线性布局getChildAt在牛轧糖中的效果不同_Android_Android Layout - Fatal编程技术网

Android 线性布局getChildAt在牛轧糖中的效果不同

Android 线性布局getChildAt在牛轧糖中的效果不同,android,android-layout,Android,Android Layout,我将此布局作为TableRow的第一个子项: <LinearLayout style="@style/BodyAllegati" android:layout_width="0dp" android:layout_weight="0.65" android:paddingLeft="0dp" android:orientation="horizontal"> <LinearLayout

我将此布局作为TableRow的第一个子项:

<LinearLayout style="@style/BodyAllegati"
        android:layout_width="0dp"
        android:layout_weight="0.65" 
        android:paddingLeft="0dp"
        android:orientation="horizontal">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <ImageView
                android:id="@+id/locGpsIcon"
                android:layout_gravity="center_vertical"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingLeft="2dp"
                android:scaleType="center"
                tools:ignore="ContentDescription"/>
            <LinearLayout
                style="@style/BodySegnalini"
                android:layout_width="match_parent"
                android:orientation="horizontal"
                android:paddingLeft="0dp">
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
碰巧的是,所有这些都能在旧的Android版本中正常工作。如果我在安卓7中运行应用程序,colSeg为空


任何帮助都将不胜感激。

我猜您有两个布局,一个在layout-v24中,而您忘记了在其中添加布局。
因此,您必须在两种布局中添加我也会遇到的更改。这是一个严重的错误
LinearLayout colAll = (LinearLayout) r.getChildAt(0); // outer l.layout (r is the TableRow)
LinearLayout colAllChild = (LinearLayout) colAll.getChildAt(0); // first inner l.layout
LinearLayout colSeg = (LinearLayout) colAllChild.getChildAt(1); // l.layout after the ImageView