记录我的bug,关于setVisibility()出现的奇怪问题
2015-12-08 15:26
393 查看
啥都不说,先看代码
RelativeLayout insuranceChild = (RelativeLayout) findViewById(R.id.insuranceChild);
insuranceChild.setVisibility(View.GONE);
RelativeLayout insuranceAgecoverAge = (RelativeLayout) findViewById(R.id.insuranceAgecoverAge);
insuranceAgecoverAge.setVisibility(View.GONE);
RelativeLayout insuranceLimit = (RelativeLayout) findViewById(R.id.insuranceLimit);
insuranceLimit.setVisibility(View.VISIBLE);
没有什么问题吧,外层是linearLayout,下面还有其他布局,但是,模拟器,nexus5没问题,在小米,三星就出现下面的布局全部消失的情况,一个劲的找啊,
然后看布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/Appointment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F2F2F2" >
<ScrollView
android:id="@+id/ScrollView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginBottom="50dip"
android:background="#F2F2F2"
android:fillViewport="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="#fefefefe"
android:gravity="center_vertical" >
<TextView
android:id="@+id/appointment_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:text="中融信托-兴创美林湖"
android:textColor="#404040"
android:textSize="18sp"
android:textStyle="bold" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/main_listitem_view_h" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:background="#F2F2F2"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="52dip"
android:layout_marginTop="10dp"
android:background="#DBDBDB"
android:padding="1dp" >
<EditText
android:id="@+id/appointment_name"
android:layout_width="match_parent"
android:layout_height="52dp"
android:background="#fefefefe"
android:hint="理财师姓名"
android:paddingLeft="10dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="52dp"
android:layout_marginTop="10dp"
android:background="#DBDBDB"
android:padding="1dp" >
<EditText
android:id="@+id/app_phoneNumber"
android:layout_width="match_parent"
android:layout_height="52dp"
android:background="#fefefefe"
android:hint="理财师电话"
android:paddingLeft="10dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="52dp"
android:layout_marginTop="10dp"
android:background="#DBDBDB"
android:padding="1dp" >
<RelativeLayout
android:id="@+id/ins_fujiaxian"
android:layout_width="match_parent"
android:layout_height="52dp"
android:background="#fefefefe"
android:gravity="center_vertical" >
<TextView
android:id="@+id/app_money"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:background="#fefefefe"
android:text="预约金额"
android:textColor="#ffbbbbbb"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="3dp"
android:background="@drawable/arrow" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_marginTop="10dp"
android:background="#DBDBDB"
android:padding="1dp" >
<EditText
android:id="@+id/app_content"
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="#fefefefe"
android:gravity="top"
android:hint="其他说明"
android:maxLength="50"
android:paddingLeft="10dp"
android:paddingTop="18dp" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="45dip"
android:layout_alignParentBottom="true"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_marginTop="2dp" >
<Button
android:id="@+id/btn_post"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dip"
android:background="#BB8855"
android:text="提交预约"
android:textColor="#fefefefe" />
</RelativeLayout>
</RelativeLayout>
看起来也没有问题吧,奇怪的是,三个RelateLayout必须两个以上显示,才会正常,毫无头绪寻找
最后
就说一个词
view
杨峥啊,你这布局
RelativeLayout insuranceChild = (RelativeLayout) findViewById(R.id.insuranceChild);
insuranceChild.setVisibility(View.GONE);
RelativeLayout insuranceAgecoverAge = (RelativeLayout) findViewById(R.id.insuranceAgecoverAge);
insuranceAgecoverAge.setVisibility(View.GONE);
RelativeLayout insuranceLimit = (RelativeLayout) findViewById(R.id.insuranceLimit);
insuranceLimit.setVisibility(View.VISIBLE);
没有什么问题吧,外层是linearLayout,下面还有其他布局,但是,模拟器,nexus5没问题,在小米,三星就出现下面的布局全部消失的情况,一个劲的找啊,
然后看布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/Appointment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F2F2F2" >
<ScrollView
android:id="@+id/ScrollView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginBottom="50dip"
android:background="#F2F2F2"
android:fillViewport="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="#fefefefe"
android:gravity="center_vertical" >
<TextView
android:id="@+id/appointment_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:text="中融信托-兴创美林湖"
android:textColor="#404040"
android:textSize="18sp"
android:textStyle="bold" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/main_listitem_view_h" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:background="#F2F2F2"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="52dip"
android:layout_marginTop="10dp"
android:background="#DBDBDB"
android:padding="1dp" >
<EditText
android:id="@+id/appointment_name"
android:layout_width="match_parent"
android:layout_height="52dp"
android:background="#fefefefe"
android:hint="理财师姓名"
android:paddingLeft="10dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="52dp"
android:layout_marginTop="10dp"
android:background="#DBDBDB"
android:padding="1dp" >
<EditText
android:id="@+id/app_phoneNumber"
android:layout_width="match_parent"
android:layout_height="52dp"
android:background="#fefefefe"
android:hint="理财师电话"
android:paddingLeft="10dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="52dp"
android:layout_marginTop="10dp"
android:background="#DBDBDB"
android:padding="1dp" >
<RelativeLayout
android:id="@+id/ins_fujiaxian"
android:layout_width="match_parent"
android:layout_height="52dp"
android:background="#fefefefe"
android:gravity="center_vertical" >
<TextView
android:id="@+id/app_money"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:background="#fefefefe"
android:text="预约金额"
android:textColor="#ffbbbbbb"
android:textSize="18sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="3dp"
android:background="@drawable/arrow" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_marginTop="10dp"
android:background="#DBDBDB"
android:padding="1dp" >
<EditText
android:id="@+id/app_content"
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="#fefefefe"
android:gravity="top"
android:hint="其他说明"
android:maxLength="50"
android:paddingLeft="10dp"
android:paddingTop="18dp" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="45dip"
android:layout_alignParentBottom="true"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_marginTop="2dp" >
<Button
android:id="@+id/btn_post"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dip"
android:background="#BB8855"
android:text="提交预约"
android:textColor="#fefefefe" />
</RelativeLayout>
</RelativeLayout>
看起来也没有问题吧,奇怪的是,三个RelateLayout必须两个以上显示,才会正常,毫无头绪寻找
最后
就说一个词
view
杨峥啊,你这布局
相关文章推荐
- android 代码实现控件之间的间距
- SourceProvider.getJniDirectories
- Android布局的小窍门?
- Web布局连载——两栏固定布局(五)
- [Android]在代码里运行另一个程序的方法
- Trac 中文语言安装
- 肯特·贝克:改变人生的代码整理魔法
- 雷军是谁,他为什么而奋斗?小米上市和雷军的英雄主义
- 软件 bug 的生命周期
- 网页恶意代码的预防
- Firefox2中输入框丢失光标bug的解决方法
- 高手写的Tracer-Flash代码调试类代码下载
- CSS代码缩写技巧
- 样式表CSS布局经验
- 非主流Q-zOne代码代码搜集第1/2页
- CreateWeb.vbs 代码
- for命令的一些bug分析
- Lua中编译执行代码相关的函数详解
- 修正IE下使用CSS属性overflow的bug
- css网页布局中注意的几个问题小结