Android的布局中存在的缺陷

来源:互联网 发布:360禁用软件联网 编辑:程序博客网 时间:2024/04/28 09:43

学了好久,原来是被Android的几个bug搞得分不清方向了!
android.support.v4.app.FragmentTabHost这个东西有点bug,原因是3.0留下的问题,而为了兼容性,所以3.0以后的不再(官方推荐)使用TabActivity这变态东西,推荐使用Fragment代替,因而tabcontent也随之废弃掉(不是真正的废弃)。二网上还有很多关于Tabactivity过时的例子。要想使用tabhost这个功能,并使用fragmen,因而有以下这个变态的布局:

<android.support.v4.app.FragmentTabHost        xmlns:android="http://schemas.android.com/apk/res/android"        android:id="@android:id/tabhost"        android:layout_width="match_parent"        android:layout_height="match_parent">    <LinearLayout            android:orientation="vertical"            android:layout_width="match_parent"            android:layout_height="match_parent">        <FrameLayout                android:id="@android:id/tabcontent"                android:layout_width="0dp"                android:layout_height="0dp"                android:layout_weight="0"/>        <FrameLayout                android:id="@+id/realtabcontent"                android:layout_width="match_parent"                android:layout_height="0dp"                android:layout_weight="1"/>        <TabWidget                android:id="@android:id/tabs"                android:orientation="horizontal"                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:layout_weight="0"/>    </LinearLayout></android.support.v4.app.FragmentTabHost>

(红色字段,看到没? android:layout_width=”0dp” android:layout_height=”0dp” android:layout_weight=”0”/只能设置为0,也就是说把这个tabcontent过时的老家伙强制隐藏掉)。

希望Android的下一个bug不要这么蛋疼!!!
有时候一连几天在学习那个BUG!学到你想崩溃,但有不能崩溃的境界

真的是要:苦其心志劳其筋骨饿其体肤、空乏其身、行拂乱其所为、所以动心忍性增益其所不能。

bug详解: http://blog.csdn.net/wklbeta/article/details/11329207

0 0
原创粉丝点击