按钮宽度与父级android不匹配

按钮宽度与父级android不匹配,第1张

概述我有以下xml:<?xmlversion="1.0"encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apkes/android"android:layout_width="wrap_content"android:layout_height="wrap_content"

我有以下xml:

 <?xml version="1.0" enCoding="utf-8"?> <linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:layout_wIDth="wrap_content"androID:layout_height="wrap_content"androID:orIEntation="vertical" >    <TextVIEw    androID:ID="@+ID/text_vIEw"    androID:layout_wIDth="wrap_content"    androID:layout_height="match_parent"    androID:layout_gravity="center_horizontal|center_vertical"    androID:layout_margintop="20dip"    androID:text="Fragment1"    androID:textAppearance="?androID:attr/textAppearanceLarge"    androID:textSize="30dip" />    <button         androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:text="button1"/> <GrIDVIEw       androID:ID="@+ID/grIDvIEw"      androID:layout_wIDth="wrap_content"       androID:layout_height="match_parent"overla      androID:columnWIDth="90dp"      androID:numColumns="auto_fit"      androID:verticalSpacing="10dp"      androID:horizontalSpacing="10dp"      androID:stretchMode="columnWIDth"      androID:gravity="center"/>                                    <button         androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:text="button1"/> </linearLayout>

button1用于切换网格视图的可见性.但是,当网格视图不可见时,按钮不会填满屏幕.他们占据了屏幕的一半.当网格视图可见时,按钮占据了我想要的所有屏幕.我无法理解这种奇怪的行为.

解决方法:

尝试将linear布局的宽度更改为match_parent

<linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:layout_wIDth="match_parent"androID:layout_height="wrap_content"androID:orIEntation="vertical" >
总结

以上是内存溢出为你收集整理的按钮宽度与父级android不匹配全部内容,希望文章能够帮你解决按钮宽度与父级android不匹配所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1106401.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存