安卓疑难杂症解决指南

安卓疑难杂症解决指南

1.
\u3000
用于TextView中文字的空格
2.
android怎样将textview置于imageview之上
使用FrameLayout布局

FrameLayout
android:layout_width=”match_parent”
android:layout_height=”wrap_content”>

<ImageView
    android:layout_marginTop="50dp"
    android:layout_width="match_parent"
    android:layout_height="33dp"

    android:background= "@mipmap/ic_line1"
    android:layout_weight="0.03" />

<TextView
    android:textColor="@color/black"
    android:layout_marginTop="58dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:text="@string/langduzhe"
    android:layout_weight="0.03" />
    </FrameLayout>容

3.
android TextView改变部分字体颜色

textview = (TextView) findViewById(R.id.textview);
SpannableStringBuilder ssbuilder = new SpannableStringBuilder(textview.getText().toString());
//ForegroundColorSpan–文字前景色,BackgroundColorSpan–文字背景色
ForegroundColorSpan yellowSpan = new ForegroundColorSpan(Color.YELLOW);
ssbuilder.setSpan(yellowSpan, 11,15, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
textview.setText(ssbuilder);
4.
解决Android 5.0以上版本Button自带阴影效果的方法
style=”?android:attr/borderlessButtonStyle”
5.
设置背景图片透明
View v=findViewById(R.id.image4);
v.getBackground().mutate().setAlpha(190);
6.
设置收藏按钮类似的点击变换图片再点击恢复

final ImageButton button = (ImageButton) view.findViewById(R.id.bt_love);

final int[] flag = {0};

button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {

        if(flag[0] ==0){

            button.setBackgroundResource(R.mipmap.ic_love_normal);
            flag[0] = 1;
        }else{

            button.setBackgroundResource(R.mipmap.ic_love_select);
            flag[0] = 0;
        }

    }
});

2017.5.11
7.取消 EditText 自动聚焦弹出输入法界面
在EditText的父控件中加上这两行代码即可:

android:focusable="true" 

android:focusableInTouchMode="true"

这里写图片描述

2017.6.6
8.取消android studio默认大写
在Values下的styles.xml中加入

<item name="android:textAllCaps">false</item>

即可。

9.给按钮增加水波纹

 android:background="?attr/selectableItemBackground"
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值