关于
近期工作项目进入尾声,许多界面需要修改,包括样式,布局,字体大小颜色,提示颜色等等,忙的焦头烂额(UI让我头大)
学习一
场景:我们通常布局中会给我们的文本或是编辑文本设置一个textColor,但是可能会有这样需求,就是未选择前的提示颜色是灰色的(颜色代码:#808080),选择以后颜色要求是黑色的,以示区分。这就需要我们代码中动态修改了。
设置text的颜色的方法也很简单:
textView.setTextColor(getContext().getResources().getColor(R.color.black)); 因为有的不是活动页面所以用的getContext()方法。
然后R.color.black就是我们res/values/colors.xml文件下的black颜色了。
效果就不奉上了。
学习二
**场景:当前活动页面有多个EditText时候会在最上面的输入框中自动获取焦点。**如下:
解决办法:
网上有说是在edittext中添加如下:
android:focusableInTouchMode="true"
android:focusable="true"
没啥用。
亲测办法: 在这个EditText的父级控件中增加以下两句:
android:focusableInTouchMode="true"
android:focusable="true"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:focusable="true"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="@drawable/xian" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="@+id/ac_edt_content"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="21dp"
android:layout_weight="2"
android:hint="请输入桶编号"
android:background="@drawable/input_text_normal_style"
android:gravity="center_vertical"
android:inputType="number|numberDecimal"
android:maxLength="20"
android:textSize="15sp"
android:padding="5dp"
android:textColorHint="@color/gray" />
</LinearLayout>
实现结果图就不放了。
学习三
场景:在当前页面用户切入后台,即app进入后台,假如一些操作是进入这个页面就要刷新一次的。
方法:使用OnResume()方法。在这里面进行刷新的操作。
学习四
场景:在当前页面用户切入后台,即app进入后台,桌面上重新打开app需要其留在退出时候的页面
其实这个需求不是很一般的需求(困扰了我一天的时间),刚接手时候我这边app测试A页面退出到后台,从新打开还是A页面。测试人员测试却说是退出后台重新打开。然后我想是不是因为系统啥的原因,毕竟有的android是定制的,(好吧事实上是正规系统),然后我用的模拟器是7.0的,测试人员是用的10的,难道是这个问题? 百度了一下。。没有相关的。然后搜了一下这方面的。绝大数都是说在启动页的oncreate方法里面加上:
if (!isTaskRoot()) {
finish();
return;
}
后面将主界面设置成了singletask,问题暂时解决(主要是需求不是太紧要,就没有继续。)