当前位置: 移动技术网 > 移动技术>移动开发>Android > 跟着第二行代码回顾android

跟着第二行代码回顾android

2018年03月18日  | 移动技术网移动技术  | 我要评论

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.当很多页面需要用一个相同的布局,我们可以将这些布局写在一个布局文件中,然后在每个页面引入它就可以用了,有效避免了大量的重复代码
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();
            }
        });
    }
然后在其他布局界面就能够引用了



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

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网