Android入门之控件布局初步
2023-09-11 14:16:05 时间
布局方法分类:
实例:
1.实现Linear布局
代码清单:
1. MainActivity.java
package com.jk.test; import android.os.Bundle; import android.app.Activity; import android.view.Menu; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.first_layout); @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true;2.first_layout.xml
?xml version="1.0" encoding="utf-8"? LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#ff0000" android:text="first"/ TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#00ff00" android:text="second"/ /LinearLayout
2.first_layout.xml
?xml version="1.0" encoding="utf-8"? LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#ff0000" android:text="first"/ TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#00ff00" android:text="second"/ /LinearLayout相应的使用不同的布局需要修改你的xml文件即可。
Android自定义控件 | 源码里有宝藏之自动换行控件 回想一下在作文本上写作的场景,当从左到右写满一行后,会切换到下一行的开头继续写。如果把“作文本”比作容器控件,把“字”比作子控件。Android 原生控件中没有能“自动换行”的容器控件。
Android控件之ProgressBar ProgressBar位于android.widget包下,其继承于View,主要用于显示一些操作的进度。应用程序可以修改其长度表示当前后台操作的完成情况。因为进度条会移动,所以长时间加载某些资源或者执行某些耗时的操作时,不会使用户界面失去响应。ProgressBar类的使用非常简单,只需将其显示到前台,然后启动一个后台线程定时更改表示进度的数值即可
相关文章
- Android 自定义控件开发入门 (三)
- React Native Android入门实战及深入源码分析系列(2)——React Native源码编译
- Android 开发之旅:短信的收发及在android模拟器之间实践(一)
- Android OpenGL 入门示例----绘制三角形和正方形
- 《android开发艺术探索》读书笔记(十五)--Android性能优化
- macos:安装java 17.0.6(android studio报错:Unable to locate a Java Runtime.)
- Android开发学习---android下的数据持久化,保存数据到rom文件,android_data目录下文件访问的权限控制
- 1、Android Studio集成极光推送(Jpush) 报错 java.lang.UnsatisfiedLinkError: cn.jpush.android.service.PushProtoco
- Android 3.0 r1 API中文文档(113) ——SlidingDrawer
- Android Studio / IDEA 中.android 文件夹移动出默认位置
- Android GIS开发系列-- 入门季(2) MapView与图层介绍
- Android 10开机执行sh脚本文件
- Android PhoneWindowManager监听屏幕右侧向左滑动实现返回功能
- android高手进阶教程
- Android ijkplayer轮流播放和播放raw assets视频
- 【Android Gradle 插件】自定义 Gradle 插件优化图片 ② ( 压缩 png、jpg 图片 | 使用 pngcrush 压缩工具压缩 png 图片 )
- cordova+vue 项目打包成Android(apk)应用
- Android各个版本API的区别
- Android入门第八篇之GridView(九宫图)