跟着第二行代码回顾android--各种控件

1.button的属性textAllCaps=false,可是控制输入的小写字母不变成大写。

2.progressBar默认是圆形的,在xml文件中加入以下属性可以变成长条形的

style="?android:attr/progressBarStyleHorizontal"
3.谷歌已经不推荐使用progressDialog,因为使用进度条的交互更加优秀。

4.android的基本布局:LinearLayout线性布局,RelativeLayout相对布局,FrameLayout帧布局,百分比布局。

讲一下百分比布局,它需要导入android support库

compile 'com.android.support:percent:26.0.0-alpha1'

它包含

android.support.percent.PercentFrameLayout

android.support.percent.PercentRelativeLayout

宽高的设置不会自定提示,因为它不在基础support中

app:layout_widthPercent="50%"
app:layout_heightPercent="50%"

5.当很多页面需要用一个相同的布局,我们可以将这些布局写在一个布局文件中,然后在每个页面引入它就可以用了,有效避免了大量的重复代码

<include layout="@layout/title"/>

6.自定义控件:创建一个类让它继承跟布局的类比如LinearLayout,然后重写带两个参数的构造函数,第一个参数是布局名称,第二个参数是给加载好的布局再添加一个父控件,这里指定为TitleLayout,所以写this。

public TitleLayout(final Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater.from(context).inflate(R.layout.title,this);
        Button left=(Button) findViewById(R.id.left);
        left.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                ((Activity)context).finish();
            }
        });
        Button right=findViewById(R.id.right);
        right.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(context,"click the edit",Toast.LENGTH_LONG).show();
            }
        });
    }
然后在其他布局界面就能够引用了

<com.myapplication.TitleLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    </com.myapplication.TitleLayout>

7.listview和recyclerView的内容竟然丢失了!!!!!!!!!!!!!!!!不想重写。等以后再来回顾吧



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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值