Android 视图View的基本属性
来源:互联网 发布:c语言编程求最简分数 编辑:程序博客网 时间:2024/06/06 00:21
View是Android的基本视图,所有的控件和布局都是从View类直接或者间接的派生而来的。所以View的基本属性和方法对所有的控件和布局是通用的,知道这些基本的属性和方法,在看其他控件和布局就容易的多了。
下面我们用一个示例来看下View都有哪些基本属性。
让我们看下代码运行效果:
然后在让我们看下滚动视图ScrollView的xml用法示例。
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center" tools:context="com.easygoing.day1.MainActivity"> <HorizontalScrollView android:layout_width="wrap_content" android:layout_height="200dp" > <LinearLayout android:layout_width="wrap_content" android:layout_height="match_parent" android:orientation="horizontal"> <View android:layout_width="200dp" android:layout_height="match_parent" android:background="@android:color/holo_red_dark"> </View> <View android:layout_width="200dp" android:layout_height="match_parent" android:background="@android:color/holo_purple"> </View> </LinearLayout> </HorizontalScrollView> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <View android:layout_width="match_parent" android:layout_height="40dp" android:background="@android:color/holo_green_dark"> </View> <View android:layout_width="match_parent" android:layout_height="40dp" android:background="@android:color/holo_blue_dark"> </View> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="我是滚动视图的文本" android:gravity="center"/> </LinearLayout> </ScrollView></LinearLayout>
运行效果
当我们需要将scrollview视图充满屏幕的时候,需这样设置:
android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true"
然后我加了一个背景色好看清楚效果。
阅读全文
0 0
- Android 视图View的基本属性
- 视图View的基本属性
- android 最基本的自定义View属性
- Android的视图(View)
- Android自定义View的基本步骤和使用自定义属性
- Android开发中的View类的视图属性focusableInTouchMode这个属性跟focusable有什么区别?
- Android开发中的View类的视图属性focusableInTouchMode这个属性跟focusable有什么区别?
- Android开发中的View类的视图属性focusableInTouchMode这个属性跟focusable有什么区别?
- Android View的属性
- Android视图绘制View相关概念基本总结
- android 自定义View的属性
- Android View的xml属性
- Android View的xml属性
- android view的xml属性
- android view的xml属性
- Android View的可见属性
- android自定义view的属性
- android view视图的层叠(叠加)
- Linux命令(17)——su与sudo命令
- Unity中Sprite和UI Image的区别
- 爬虫感悟3
- day-11:读取项目中的所有pom.xml文件中所有的version标签
- 初入IT行业,从小白开始
- Android 视图View的基本属性
- 显式锁(四)--- Lock的等待/通知机制Condition
- HTML5
- Vulkan规范:第八章 8.2 ~ 8.3
- Java反射
- 行程长度编码科普
- 文章标题
- [系统安全]使用OD编写连连看外挂
- day-11