Android UI设计随笔
16lz
2021-01-23
1.Android中ImageView默认效果图片上下出现空白,怎么使ImageView自适应图片大小?
在ImageView中加入android:adjustViewBounds="true"属性即可
// 指定移动像素
android:layout_marginTop上偏移的值;
android:layout_marginBottom 下偏移的值;
android:layout_marginLeft 左偏移的值;
android:layout_marginRight 右偏移的值;
Android中的Selector主要是用来改变ListView和Button控件的默认背景。
<?xmlversion="1.0"encoding="utf-8"?><selectorxmlns:android="http://schemas.android.com/apk/res/android"><!--默认时的背景图片--><itemandroid:drawable="@drawable/pic1"/><!--没有焦点时的背景图片--><itemandroid:state_window_focused="false"android:drawable="@drawable/pic1"/><!--非触摸模式下获得焦点并单击时的背景图片--><itemandroid:state_focused="true"android:state_pressed="true"android:drawable="@drawable/pic2"/><!--触摸模式下单击时的背景图片--><itemandroid:state_focused="false"android:state_pressed="true"android:drawable="@drawable/pic3"/><!--选中时的图片背景--><itemandroid:state_selected="true"android:drawable="@drawable/pic4"/><!--获得焦点时的图片背景--><itemandroid:state_focused="true"android:drawable="@drawable/pic5"/></selector>
属性介绍:
android:state_selected选中
android:state_focused获得焦点
android:state_pressed点击
android:state_enabled设置是否响应事件,指所有事件
更多相关文章
- Android ListView 去除边缘阴影、选中色、拖动背景色等(android:
- 设置Android app背景图片(Android studio)
- 浅谈android的selector,背景选择器
- shape带边框的背景
- EditText焦点问题
- Android之Activity透明背景
- Android如何让TextView子元素随着父元素的背景变化而改变字体颜
- android 设置Button或者ImageButton的背景透明