Android开发之细节UI学习记录(一)

Android开发之细节UI学习记录(一)

关于

近期工作项目进入尾声,许多界面需要修改,包括样式,布局,字体大小颜色,提示颜色等等,忙的焦头烂额(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,问题暂时解决(主要是需求不是太紧要,就没有继续。)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

雪の星空朝酱

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值