Android布局规范

分享一些Android布局制做的学习心得android

要点一:制做布局页面时,每一个控件的id命名须要规范,多个单词须要用_隔开web

控件                   缩写
LinearLayout           ll
RelativeLayout         rl
ConstraintLayout       cl
ListView               lv
ScollView              sv
TextView               tv
Button                 btn
ImageView              iv
CheckBox               cb
RadioButton            rb
EditText               et
复制代码

要点二:TextView优先使用"wrap_content"markdown

android:layout_width="wrap_content"
android:layout_height="wrap_content"
复制代码

要点三:设置颜色时,尽可能设置透明度,例如布局

#ff333333
android:textColor="@color/black_ff333333"
复制代码

要点四:设置背景颜色推荐在drawable下建立一个shape.xml文件,文件内容以下学习

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <corners android:radius="30dp"/>
    <solid android:color="#FFE6E6FA"/>
    <padding
        android:bottom="5dp"
        android:top="5dp"
        android:left="10dp"
        android:right="10dp"/>
</shape>
复制代码

要点五:图片文件的存放路径须要正确,不然图片显示不出来,在res文件夹下建立drawable-xxxhdpi文件包用来存放图片文件,此外图片命名使用.png、.webp以及.jpg格式spa

要点六:设置样式时推荐使用alt+enter快捷键调出资源框code

image.png

image.png

要点七:插入小符号方法:orm

步骤:在drawable下右键——new——Vector Asset——点击Clip Art选择本身须要的符号,在所需控件里输入引用代码,例如xml

android:drawableRight="@drawable/ic_baseline_chevron_right_24"
复制代码
相关文章
相关标签/搜索