大侠阿木博客
大侠阿木博客

wrap_content和fill_parent的区别与用法心得

汉化一个apk的时候,在MX3上面下拉,出现了一个情况,如下图

下拉之后丢掉了一部分东西

刷机精灵截图20140310214638

不下拉的时候原来是这样的

刷机精灵截图20140310213656

显然这个情况只会出现在有弹性下拉的ROM上,开发者选项里打开了“显示布局边界”

看看布局,发现

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">;
<LinearLayout android:gravity="top|center" android:orientation="horizontal" android:id="@id/adViewLayout" android:layout_width="fill_parent" android:layout_height="0dip" />
<LinearLayout android:gravity="top|center" android:orientation="horizontal" android:id="@id/prefs" android:layout_width="fill_parent" android:layout_height="wrap_content" />
</LinearLayout>

研究了一番把最后面的android:layout_height="wrap_content"

改成了android:layout_height="fill_parent"

就正常了,下面是修改后的下拉效果

刷机精灵截图20140310213648

 

简单分析:

fill_parent指的是填满父级布局的全部地方,意思是有多大用多大(我是这么理解的,解释可能不专业)

wrap_content指的是,用多少给多少,按需分配

 

就这样,小弟不才,谢谢欣赏,这个汉化的应用在下一篇文章中分享出来

# # #
首页      Android      Android 教程      wrap_content和fill_parent的区别与用法心得

推荐文章

大侠阿木博客

wrap_content和fill_parent的区别与用法心得
汉化一个apk的时候,在MX3上面下拉,出现了一个情况,如下图 下拉之后丢掉了一部分东西 不下拉的时候原来是这样的 显然这个情况只会出现在有弹性下拉的ROM上,开发者选项里打开了“显示…
扫描二维码继续阅读
2014-03-10