android编程中的琐碎知识点汇总(2)

2024-04-29 20:08

本文主要是介绍android编程中的琐碎知识点汇总(2),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1.控件配置 xml中有趣的属性:
android:background
可以通过以下两种方法设置背景为透明:"@android:color/transparent"和"@null"。注意TextView默认是透明的,不用写此属性,但是Buttom/ImageButton/ImageView想透明的话就得写这个属性了。
android:drawingCacheQuality
设置绘图时半透明质量。有以下值可设置:auto(默认,由框架决定)/high(高质量,使用较高的颜色深度,消耗更多的内存/low(低质量,使用较低的颜色深度,但是用更少的内存)。
android:fadingEdge
设置拉滚动条时 ,边框渐变的放向。none(边框颜色不变),horizontal(水平方向颜色变淡),vertical(垂直方向颜色变淡)。
android:fadingEdgeLength
设置边框渐变的长度。
android:scrollbarDefaultDelayBeforeFade
设置N毫秒后开始淡化,以毫秒为单位。
android:scrollbarFadeDuration
设置滚动条淡出效果(从有到慢慢的变淡直至消失)时间,以毫秒为单位。Android2.2中滚动条滚动完之后会消失,再滚动又会出来,在1.5、1.6版本里面会一直显示着。
android:scrollbarThumbHorizontal
设置水平滚动条的drawable。
android:scrollbarThumbVertical
设置垂直滚动条的drawable.
android:scrollbarTrackHorizontal
设置水平滚动条背景(轨迹)的色drawable
android:scrollbarTrackVertical
设置垂直滚动条背景(轨迹)的drawable注意直接设置颜色值如”android:color/white”将得出很难看的效果,甚至都不理解这个属性了,这里可以参见ApiDemos里res/drawable/scrollbar_vertical_thumb.xml和scrollbar_vertical_track.xml,设置代码为:android:scrollbarTrackVertical ="@drawable/scrollbar_vertical_track"
android:soundEffectsEnabled
设置点击或触摸时是否有声音效果
android:visibility
设置是否显示View。设置值:visible(默认值,显示),invisible(不显示,但是仍然占用空间),gone(不显示,不占用空间)

 

2.很经典的一个layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical" android:layout_width="fill_parent"android:padding="8px" android:background="@color/lightblue"android:layout_height="fill_parent" android:gravity="center_horizontal"><LinearLayout android:orientation="vertical"android:layout_width="fill_parent" android:layout_height="wrap_content"><TextView android:text="@string/qr_main_contents"android:textColor="@color/black" android:layout_width="wrap_content"android:layout_height="wrap_content" /><Spinner android:id="@+id/qr_main_contents"android:layout_width="wrap_content" android:layout_height="wrap_content"android:entries="@+array/qr_main_contents" android:prompt="@string/qr_main_contents" /></LinearLayout><LinearLayout android:layout_width="fill_parent"android:layout_weight="1" android:layout_height="wrap_content"android:scrollbars="vertical"><ScrollView android:layout_width="fill_parent"android:layout_height="fill_parent"><LinearLayout android:layout_width="fill_parent"android:layout_height="wrap_content" android:orientation="vertical"><TextView android:text="@string/qr_information_name"android:textColor="@color/black" android:layout_width="wrap_content"android:layout_height="wrap_content" /><EditText android:id="@+id/qr_information_name"android:textColorHint="@color/blue" android:singleLine="true"android:layout_width="fill_parent" android:layout_height="wrap_content" /><TextView android:text="@string/qr_information_company"android:textColor="@color/black" android:layout_width="wrap_content"android:layout_height="wrap_content" /><EditText android:id="@+id/qr_information_company"android:singleLine="true" android:layout_width="fill_parent"android:layout_height="wrap_content" /><TextView android:text="@string/qr_information_phone"android:textColor="@color/black" android:layout_width="wrap_content"android:layout_height="wrap_content" /><EditText android:id="@+id/qr_information_phone"android:singleLine="true" android:layout_width="fill_parent"android:layout_height="wrap_content" /><TextView android:text="@string/qr_information_email"android:textColor="@color/black" android:layout_width="wrap_content"android:layout_height="wrap_content" /><EditText android:id="@+id/qr_information_email"android:singleLine="true" android:layout_width="fill_parent"android:layout_height="wrap_content" /></LinearLayout></ScrollView></LinearLayout><LinearLayout android:orientation="vertical"android:gravity="right" android:layout_width="fill_parent"android:layout_height="wrap_content"><Button android:text="@string/qr_main_generate"android:layout_width="wrap_content" android:layout_height="wrap_content" /></LinearLayout>
</LinearLayout>

 

 

3.去掉页面的标题栏和信息栏
this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);//去掉信息栏

注意,这个设置必须放在设置布局前面,不然会报错.
setContentView(R.layout.entrancebs);

这篇关于android编程中的琐碎知识点汇总(2)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!


原文地址:
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.chinasem.cn/article/947047

相关文章

在Android平台上实现消息推送功能

《在Android平台上实现消息推送功能》随着移动互联网应用的飞速发展,消息推送已成为移动应用中不可或缺的功能,在Android平台上,实现消息推送涉及到服务端的消息发送、客户端的消息接收、通知渠道(... 目录一、项目概述二、相关知识介绍2.1 消息推送的基本原理2.2 Firebase Cloud Me

揭秘Python Socket网络编程的7种硬核用法

《揭秘PythonSocket网络编程的7种硬核用法》Socket不仅能做聊天室,还能干一大堆硬核操作,这篇文章就带大家看看Python网络编程的7种超实用玩法,感兴趣的小伙伴可以跟随小编一起... 目录1.端口扫描器:探测开放端口2.简易 HTTP 服务器:10 秒搭个网页3.局域网游戏:多人联机对战4.

Android中Dialog的使用详解

《Android中Dialog的使用详解》Dialog(对话框)是Android中常用的UI组件,用于临时显示重要信息或获取用户输入,本文给大家介绍Android中Dialog的使用,感兴趣的朋友一起... 目录android中Dialog的使用详解1. 基本Dialog类型1.1 AlertDialog(

Java并发编程必备之Synchronized关键字深入解析

《Java并发编程必备之Synchronized关键字深入解析》本文我们深入探索了Java中的Synchronized关键字,包括其互斥性和可重入性的特性,文章详细介绍了Synchronized的三种... 目录一、前言二、Synchronized关键字2.1 Synchronized的特性1. 互斥2.

Android Kotlin 高阶函数详解及其在协程中的应用小结

《AndroidKotlin高阶函数详解及其在协程中的应用小结》高阶函数是Kotlin中的一个重要特性,它能够将函数作为一等公民(First-ClassCitizen),使得代码更加简洁、灵活和可... 目录1. 引言2. 什么是高阶函数?3. 高阶函数的基础用法3.1 传递函数作为参数3.2 Lambda

Android自定义Scrollbar的两种实现方式

《Android自定义Scrollbar的两种实现方式》本文介绍两种实现自定义滚动条的方法,分别通过ItemDecoration方案和独立View方案实现滚动条定制化,文章通过代码示例讲解的非常详细,... 目录方案一:ItemDecoration实现(推荐用于RecyclerView)实现原理完整代码实现

Python异步编程中asyncio.gather的并发控制详解

《Python异步编程中asyncio.gather的并发控制详解》在Python异步编程生态中,asyncio.gather是并发任务调度的核心工具,本文将通过实际场景和代码示例,展示如何结合信号量... 目录一、asyncio.gather的原始行为解析二、信号量控制法:给并发装上"节流阀"三、进阶控制

Android App安装列表获取方法(实践方案)

《AndroidApp安装列表获取方法(实践方案)》文章介绍了Android11及以上版本获取应用列表的方案调整,包括权限配置、白名单配置和action配置三种方式,并提供了相应的Java和Kotl... 目录前言实现方案         方案概述一、 androidManifest 三种配置方式

Android WebView无法加载H5页面的常见问题和解决方法

《AndroidWebView无法加载H5页面的常见问题和解决方法》AndroidWebView是一种视图组件,使得Android应用能够显示网页内容,它基于Chromium,具备现代浏览器的许多功... 目录1. WebView 简介2. 常见问题3. 网络权限设置4. 启用 JavaScript5. D

Android如何获取当前CPU频率和占用率

《Android如何获取当前CPU频率和占用率》最近在优化App的性能,需要获取当前CPU视频频率和占用率,所以本文小编就来和大家总结一下如何在Android中获取当前CPU频率和占用率吧... 最近在优化 App 的性能,需要获取当前 CPU视频频率和占用率,通过查询资料,大致思路如下:目前没有标准的