大佬教程收集整理的这篇文章主要介绍了按钮宽度与父级android不匹配,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有以下xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://scheR_95_11845@as.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://scheR_95_11845@as.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
以上是大佬教程为你收集整理的按钮宽度与父级android不匹配全部内容,希望文章能够帮你解决按钮宽度与父级android不匹配所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。