Android学习小记

2018-11-28  本文已影响0人  冯九岁

禁止Android不跟随屏幕密度加载不同文件夹的资源

在AndroidManifest.xml文件中添加android:anyDensity="false"字段

高分辨率,一般我们把图片丢这里mipmap-hdpi

调试时默认生成的apk在:app/build/outputs/apk目录下

Android Studio 打包时 Signature Version V1 V2

发布apk做代码混淆 爱加密

match_parent和fill_parent

layout_gravity和gravity

线性布局

分隔线

<View
    android:layout_width="match_parent"
    android:layout_height="1px"
    android:background="#000000"/>

布局使用RelativeLayout+LinearLayoutweight属性搭配使用

相对布局广告弹出框Demo

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#00CCCCFF">

    <ImageView
        android:id="@+id/img1"
        android:background="#000"
        android:layout_centerInParent="true"
        android:layout_width="200dp"
        android:layout_height="200dp" />

    <ImageView
        android:id="@+id/imgCancle"
        android:layout_alignRight="@id/img1"
        android:layout_alignTop="@id/img1"
        android:background="#5555"
        android:layout_marginTop="-15dp"
        android:layout_marginRight="-10dp"
        android:layout_width="28dp"
        android:layout_height="28dp" />
</RelativeLayout>

表格布局

帧布局FrameLayout

网格布局GridLayout

低版本sdk如何使用GridLayout

<android.support.v7.widget.GridLayout>v7包一般在sdk下的sdk\extras\android\support\v7\gridlayout目录下

几个单位

布局层次越少,性能越好

设置的drawable并不能自行设置大小,在XML是无法直接设置的,所以需要在Java代码中来进行修改

上一篇 下一篇

猜你喜欢

热点阅读