<android.support.v7.widget.CardView
android:id="@+id/cv_demo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="50dp"
android:layout_centerInParent="true"
app:cardBackgroundColor="@color/colorPrimary"
app:cardElevation="18dp"
app:cardMaxElevation="18dp"
app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="true"
app:cardCornerRadius="10dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@mipmap/pic2"/>
</android.support.v7.widget.CardView>
如何平均分布tab1,tab2,tab3标签的宽度
tabLayout.setTabMode(TabLayout.MODE_FIXED);
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
把一些不能被拉伸的图片放在 drawable-nodpi 中,此图片将不会被放大,以原大小显示。
==========================================================================================
关于按键拦截事件的问题
在Android系统的中,硬件触发的事件最开始是Activity拿到的,然后它向里面的View一级级的dispatch,所以最里层的view最后拿到了事件,而它又没有孩子了,它就开始处理了(也就是响应事件)。在孩子的事件处理函数中,如果返回了false,它的父容器还是能再次拿到了事件的。如果返回了true,也就是告诉它的父容器,这事我管了,你就别过问了。
存在诸如ImageButton,Button,CheckBox等子控件中对于Click事件默认都是采取返回了false。所以你的linearlayout是拿不到事件的,因为它的孩子已经处理过了。
解决方案
不要用错控件
================================================================================================
xml中旋转view 使用
android:rotation="90"
===============================================================================================
Android -- TextView设置空格
1、代码里,空格使用 ( \u3000 ) 生效
2、xml布局里,空格使用 (& #160;) 和 ( \u3000 ) 都生效
3、string.xml 文件里,空格使用 ( \u3000 ) 生效
===============================================================================================
-
属性方法介绍
android:tint="@android:color/white"
tint :给...着色的意思。顾名思义,这个属性方法是对图片进行着色用的。有了这个方法,我们可以任意修改图片的颜色来适应主题颜色了,这样真的特别的方便,不需要搞那么多套图片资源。(图片单一透明的比较适用,例如:Icon图标)
AndoidX 中 DrawerLayout 的使用
何为 DrawerLayout
DrawerLayout 是 Google 推出的一款能够实现侧滑效果的控件,可以实现如同网易云音乐的左侧菜单效果。实现简单,且提供了很多操作方法,可满足日常的使用。由于 AndroidX 已替代 support 使用,故 DrawerLayout 类目前位于 androidx.drawerlayout.widget 包下
<?xml version="1.0" encoding="utf-8"?>
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/DrawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
DrawerLayout drawerLayout = findViewById(R.id.DrawerLayout);
drawerLayout.openDrawer(findViewById(R.id.left_layout));
=============================================
Recylerview的adapter.setHasStableIds(true)
Recylerview的item是 ImageView 和 TextView构成,当数据改变时,我们会调用 notifyDataSetChanged,这个时候列表会刷新,为了使 url 没变的 ImageView 不重新加载(图片会一闪),我们可以用
setHasStableIds(true);
使用这个,相当于给ImageView加了一个tag,tag不变的话,不用重新加载图片。但是加了这句话,会使得 列表的 数据项 重复!! 我们需要在我们的Adapter里面重写 getItemId就好了。
@Override
public long getItemId(int position) {
return position;
}
————————————————
绘制UI的时候如果不在主线程下可能会报错,这个时候会影响其他ui的绘制赵成界面绘制失败
-------------------------------------------------
关于popupwindown 的使用问题
setOutsideTouchable 这个函数的意义
setFocusable(false)
setTouchable(true) 弹出的window是不是可以接收触摸事件要不然就传递到他的下一层
控制是否向弹出窗口通知其窗口外的触摸事件。这只适用于可触摸但不可聚焦的弹出窗口,这意味着窗口外的触摸将传递到后面的窗口。默认值为false。
设置位置和动画showAsDropDown(View anchor, int xoff, int yoff, int gravity)
showAtLocation(View parent, int gravity, int x, int y)
setOnDismissListener(PopupWindow.OnDismissListener onDismissListener)
setAnimationStyle(int animationStyle)
============================================================