在我的布局文件中,我使用了根ScrollVIEw和子linearLayout.
我搜索了这个,但没有得到帮助.
我在父视图和子视图中都设置了match_parent.
但是儿童观点有问题.
子视图不像父视图那样填充.
这是图像和xml代码.
布局文件.
<?xml version="1.0" enCoding="utf-8"?><ScrollVIEw xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:CustomTextVIEw="http://schemas.androID.com/apk/res-auto" xmlns:CustomEditTextVIEw="http://schemas.androID.com/apk/res-auto" xmlns:tools="http://schemas.androID.com/tools" androID:ID="@+ID/linearLayout1" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:background="#D3D6DB" androID:orIEntation="vertical" tools:context=".tabs.MyTravelTab" > <linearLayout androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:background="@drawable/card_background_new" androID:orIEntation="vertical" > <linearLayout androID:layout_wIDth="match_parent" androID:layout_height="0dp" androID:layout_weight="1" androID:orIEntation="vertical" > <linearLayout androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_marginleft="10dp" androID:layout_marginRight="10dp" androID:layout_margintop="10dp" > <linearLayout androID:layout_wIDth="0dp" androID:layout_height="@dimen/fIEld_height" androID:layout_weight="0.4" androID:gravity="left|center_vertical" > <com.mymv.controls.CustomTextVIEw androID:ID="@+ID/textGPS" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" CustomTextVIEw:typeface="Roboto-Regular.ttf" androID:text="ABC" androID:textcolor="@color/black" androID:textSize="12sp" /> <Togglebutton androID:ID="@+ID/gps_toggle" androID:layout_wIDth="wrap_content" androID:layout_height="24dp" androID:layout_margin="5dp" androID:background="@drawable/gps_custom_toggle" androID:checked="false" androID:textOff="" androID:textOn="" /> <com.mymv.controls.CustomTextVIEw androID:ID="@+ID/textManual" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" CustomTextVIEw:typeface="Roboto-Regular.ttf" androID:text="DEF" androID:textcolor="@color/black" androID:textSize="11sp" /> </linearLayout> <Spinner androID:ID="@+ID/spinnerPurpoSEOfjourney" androID:layout_wIDth="0dp" androID:layout_height="@dimen/fIEld_height" androID:layout_weight="0.6" androID:background="@drawable/dropdown_black_border" androID:entrIEs="@array/purpose_of_journey" /> </linearLayout> <linearLayout androID:ID="@+ID/gpsLayout" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_marginleft="10dp" androID:layout_marginRight="10dp" androID:layout_margintop="10dp" androID:visibility="gone" > <linearLayout androID:ID="@+ID/startGPSBtn" androID:layout_wIDth="0dp" androID:layout_height="@dimen/fIEld_height" androID:layout_weight="0.5" androID:background="@drawable/textvIEw_green_drawable_left_curve_selector" androID:gravity="center" > <ImageVIEw androID:ID="@+ID/imageVIEw1" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:src="@drawable/gps" /> <com.mymv.controls.CustomTextVIEw androID:ID="@+ID/textVIEw1" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" CustomTextVIEw:typeface="Roboto-Regular.ttf" androID:text="START GPS" androID:textcolor="@color/white" /> </linearLayout> <linearLayout androID:ID="@+ID/endGPSBtn" androID:layout_wIDth="0dp" androID:layout_height="@dimen/fIEld_height" androID:layout_weight="0.5" androID:background="@drawable/textvIEw_red_drawable_right_curve_selector" androID:gravity="center" > <ImageVIEw androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:src="@drawable/end_flag" /> <com.mymv.controls.CustomTextVIEw androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" CustomTextVIEw:typeface="Roboto-Regular.ttf" androID:text="END GPS" androID:textcolor="@color/white" /> </linearLayout> </linearLayout> <linearLayout androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:orIEntation="vertical" androID:padding="10dp" > <linearLayout androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:gravity="center" > <com.mymv.controls.CustomTextVIEw androID:layout_wIDth="0dp" androID:layout_height="@dimen/fIEld_height" androID:layout_weight="@integer/layout_weight_textvIEw" CustomTextVIEw:typeface="Roboto-Bold.ttf" androID:background="@drawable/textvIEw_gray_drawable" androID:gravity="center_vertical" androID:padding="5dp" androID:text="DATA" androID:textcolor="@color/gray" /> <com.mymv.controls.CustomTextVIEw androID:ID="@+ID/edtTxtDate" androID:layout_wIDth="0dp" androID:layout_height="@dimen/fIEld_height" androID:layout_marginleft="-1dp" androID:layout_weight="@integer/layout_weight_edittext" CustomTextVIEw:typeface="Roboto-Regular.ttf" androID:background="@drawable/edittext_drawable_right_curv_selector" androID:gravity="center_vertical" androID:hint="DATA" androID:padding="5dp" androID:singleline="true" androID:textcolor="@color/black" androID:textcolorHint="@color/gray" androID:textSize="15dp" /> </linearLayout> <linearLayout androID:ID="@+ID/manualLayout" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:orIEntation="vertical" androID:visibility="visible" > <linearLayout androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_margintop="10dp" androID:gravity="center" > <com.mymv.controls.CustomTextVIEw androID:layout_wIDth="0dp" androID:layout_height="@dimen/fIEld_height" androID:layout_weight="@integer/layout_weight_textvIEw" CustomTextVIEw:typeface="Roboto-Bold.ttf" androID:background="@drawable/textvIEw_gray_drawable" androID:gravity="center_vertical" androID:padding="5dp" androID:text="DATA" androID:textcolor="@color/gray" /> <com.mymv.controls.CustomEditTextVIEw androID:ID="@+ID/edtTxtStartodometer" androID:layout_wIDth="0dp" androID:layout_height="@dimen/fIEld_height" androID:layout_marginleft="-1dp" androID:layout_weight="@integer/layout_weight_edittext" CustomTextVIEw:typeface="Roboto-Regular.ttf" androID:background="@drawable/edittext_drawable_right_curv_selector" androID:focusable="false" androID:gravity="center_vertical" androID:hint="DATA" androID:inputType="number" androID:maxLength="6" androID:padding="5dp" androID:singleline="true" androID:textcolor="@color/black" androID:textcolorHint="@color/gray" androID:textSize="15dp" /> </linearLayout> <linearLayout androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_margintop="10dp" androID:gravity="center" > <com.mymv.controls.CustomTextVIEw androID:layout_wIDth="0dp" androID:layout_height="@dimen/fIEld_height" androID:layout_weight="@integer/layout_weight_textvIEw" CustomTextVIEw:typeface="Roboto-Bold.ttf" androID:background="@drawable/textvIEw_gray_drawable" androID:gravity="center_vertical" androID:padding="5dp" androID:text="DATA" androID:textcolor="@color/gray" /> <com.mymv.controls.CustomEditTextVIEw androID:ID="@+ID/edtTxtEndodometer" androID:layout_wIDth="0dp" androID:layout_height="@dimen/fIEld_height" androID:layout_marginleft="-1dp" androID:layout_weight="@integer/layout_weight_edittext" CustomEditTextVIEw:typeface="Roboto-Regular.ttf" androID:background="@drawable/edittext_drawable_right_curv_selector" androID:focusable="false" androID:gravity="center_vertical" androID:hint="DATA" androID:inputType="number" androID:maxLength="6" androID:padding="5dp" androID:singleline="true" androID:textcolor="@color/black" androID:textcolorHint="@color/gray" androID:textSize="15dp" /> </linearLayout> </linearLayout> <linearLayout androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_margintop="10dp" androID:gravity="center" > <com.mymv.controls.CustomTextVIEw androID:layout_wIDth="0dp" androID:layout_height="@dimen/fIEld_height" androID:layout_weight="@integer/layout_weight_textvIEw" CustomTextVIEw:typeface="Roboto-Bold.ttf" androID:background="@drawable/textvIEw_gray_drawable" androID:gravity="center_vertical" androID:padding="5dp" androID:text="DATA" androID:textcolor="@color/gray" /> <com.mymv.controls.CustomEditTextVIEw androID:ID="@+ID/edtTxtStartLocation" androID:layout_wIDth="0dp" androID:layout_height="@dimen/fIEld_height" androID:layout_marginleft="-1dp" androID:layout_weight="@integer/layout_weight_edittext" CustomEditTextVIEw:typeface="Roboto-Regular.ttf" androID:background="@drawable/edittext_drawable_right_curv_selector" androID:focusable="false" androID:gravity="center_vertical" androID:hint="DATA" androID:maxLength="100" androID:padding="5dp" androID:singleline="true" androID:textcolor="@color/black" androID:textcolorHint="@color/gray" androID:textSize="15dp" /> </linearLayout> <linearLayout androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_margintop="10dp" androID:gravity="center" > <com.mymv.controls.CustomTextVIEw androID:layout_wIDth="0dp" androID:layout_height="@dimen/fIEld_height" androID:layout_weight="@integer/layout_weight_textvIEw" CustomTextVIEw:typeface="Roboto-Bold.ttf" androID:background="@drawable/textvIEw_gray_drawable" androID:gravity="center_vertical" androID:padding="5dp" androID:text="DATA" androID:textcolor="@color/gray" /> <com.mymv.controls.CustomEditTextVIEw androID:ID="@+ID/edtTxtEndLocation" androID:layout_wIDth="0dp" androID:layout_height="@dimen/fIEld_height" androID:layout_marginleft="-1dp" androID:layout_weight="@integer/layout_weight_edittext" CustomEditTextVIEw:typeface="Roboto-Regular.ttf" androID:background="@drawable/edittext_drawable_right_curv_selector" androID:focusable="false" androID:gravity="center_vertical" androID:hint="DATA" androID:maxLength="100" androID:padding="5dp" androID:singleline="true" androID:textcolor="@color/black" androID:textcolorHint="@color/gray" androID:textSize="15dp" /> </linearLayout> <button androID:ID="@+ID/btnRecord" androID:layout_wIDth="match_parent" androID:layout_height="@dimen/fIEld_height" androID:layout_margintop="10dp" androID:background="@drawable/button_blue_border" androID:text="button" androID:textcolor="@color/white" androID:textSize="15dp" /> </linearLayout> </linearLayout> <linearLayout androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:orIEntation="horizontal" > <button androID:ID="@+ID/vIEwUsage" androID:layout_wIDth="0dp" androID:layout_height="wrap_content" androID:layout_margin="10dp" androID:layout_weight="0.5" androID:background="@drawable/button_background_yellow" androID:padding="10dp" androID:text="button1" androID:textcolor="@color/black" /> <button androID:ID="@+ID/vIEwTravelHistory" androID:layout_wIDth="0dp" androID:layout_height="wrap_content" androID:layout_margin="10dp" androID:layout_weight="0.5" androID:background="@drawable/button_background_blue" androID:padding="10dp" androID:text="button2" androID:textcolor="@color/white" /> </linearLayout> </linearLayout></ScrollVIEw>
解决方法:
在你的scrollvIEw中尝试androID:fillVIEwport =“true”.
总结以上是内存溢出为你收集整理的Android match_parent无法按预期工作全部内容,希望文章能够帮你解决Android match_parent无法按预期工作所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)