android UI 标签

发布时间:2019-06-15 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了android UI 标签脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

1.TextView
如下 设置基本的度,高度,值,控件位置,默认值等等

 <TextView
        andROId:layout_width="100dp"
        android:layout_height="wrap_content"
        android:gravity="right"
        android:text="用户名" />

2.EditText
如下:这个是个编辑标签 相当于input type=‘text’ 设置基本的宽度,高度,当点击这个标签时。会自动调用输入键盘

<EditText
                    android:layout_width="300dp"
                    android:layout_height="wrap_content" />

3.Button标签
如下:设置id 相当于htML的id 设置宽度高度,默认值等

<Button
        android:id="@+id/button5"
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_text= "button5"
        android_layout_weight="1"/>

4.Android中RelativeLayout各个属性的含义

Android:layout_above="@id/xxx"  --将控件置于给定ID控件之上
android_layout_below="@id/xxx"  --将控件置于给定ID控件之下

android_layout_toLeftOf="@id/xxx"  --将控件的右边缘和给定ID控件的左边缘对齐
android_layout_toRightOf="@id/xxx"  --将控件的左边缘和给定ID控件的右边缘对齐

android_layout_alignLeft="@id/xxx"  --将控件的左边缘和给定ID控件的左边缘对齐
android_layout_alignTop="@id/xxx"  --将控件的上边缘和给定ID控件的上边缘对齐
android_layout_alignRight="@id/xxx"  --将控件的右边缘和给定ID控件的右边缘对齐
android_layout_alignBottom="@id/xxx"  --将控件的底边缘和给定ID控件的底边缘对齐
android_layout_alignParentLeft="true"  --将控件的左边缘和父控件的左边缘对齐
android_layout_alignParentTop="true"  --将控件的上边缘和父控件的上边缘对齐
android_layout_alignParentRight="true"  --将控件的右边缘和父控件的右边缘对齐
android_layout_alignParentBottom="true" --将控件的底边缘和父控件的底边缘对齐
android_layout_centerInParent="true"  --将控件置于父控件的中心位置
android_layout_centerHorizontal="true"  --将控件置于水平方向的中心位置
android_layout_centerVertical="true"  --将控件置于垂直方向的中心位置

5.android bundle
如下:就把name为张三这个数据从A传到了B.

Intent it = new Intent(A.this,B.class);  
  
Bundle bundle = new Bundle();  
  
bundle.putString("name","张三");  
  
it.putExtrats(bundle);  
  
startActivity(it);  

6.安卓下拉框

html 中的下拉框是 select标签加一些option
android中的下拉框是Spinner组件

如下将一个下拉框传到页面


        spinner = (Spinner) findViewById(R.id.spinner);
        //数据
        data_list = new ArrayList<String>();
        data_list.add("北京");
        data_list.add("上海");
        data_list.add("广州");
        data_list.add("深圳");

        //适配器
        arr_adapter= new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, data_list);
        //设置样式
        arr_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        //加载适配器
        spinner.setAdapter(arr_adapter);
        
        还需要设置静态资源 array.xml
        
        <?xml version="1.0" encoding="utf-8"?>
        <resources>
            <string-array name="spingarr">
                <item>北京</item>
                <item>上海</item>
                <item>广州</item>
                <item>深圳</item>
            </string-array>
        </resources>
        

7.android页面之间的跳转

html 当中跳转直接用 a标签 或者js的href 
android则需要用组件 Intent

Intent intent = new Intent(SecondActivity.this,ThirdActivity.class);
                startActivity(intent);
//表示从SecondActivity跳到ThirdActivity

脚本宝典总结

以上是脚本宝典为你收集整理的android UI 标签全部内容,希望文章能够帮你解决android UI 标签所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。