Android开发-selector-setSelected-AndroidStudio
来源:互联网 发布:mac微信接收的文件 编辑:程序博客网 时间:2024/04/30 17:26
selector_1.xml:
<?xml version="1.0" encoding="utf-8" ?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="false" android:drawable="@drawable/png01" /> <item android:state_selected="true" android:drawable="@drawable/png02" /></selector>
selector_2.xml:
<?xml version="1.0" encoding="utf-8" ?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="false" android:drawable="@drawable/png03" /> <item android:state_selected="true" android:drawable="@drawable/png04" /></selector>activity_main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="#ffffff" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity" > <FrameLayout android:id="@+id/oneFragment_container" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/buttonList"> </FrameLayout> <FrameLayout android:id="@+id/twoFragment_container" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/buttonList"> </FrameLayout> <FrameLayout android:id="@+id/threeFragment_container" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/buttonList"> </FrameLayout> <View android:layout_width="fill_parent" android:layout_height="1px" android:background="?android:attr/listDivider" android:layout_below="@+id/oneFragment_container" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" /> <!--我是一条黑线--> <ImageView android:layout_above="@+id/buttonList" android:layout_width="fill_parent" android:layout_height="0.1dp" android:background="#000000" /> <LinearLayout android:id="@+id/buttonList" android:background="#ffffff" android:layout_width="fill_parent" android:layout_height="50sp" android:layout_alignParentBottom="true" android:orientation="horizontal" > <!--android:id="@+id/oneLinearLayout"--> <LinearLayout android:id="@+id/oneLinearLayout" android:layout_margin="1dp" android:layout_width="match_parent" android:layout_weight="1" android:orientation="vertical" android:layout_height="match_parent"> <ImageView android:id="@+id/imageView_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/selector_1" /> </LinearLayout> <!--android:id="@+id/rbAddress"--> <LinearLayout android:id="@+id/twoLinearLayout" android:layout_margin="1dp" android:layout_width="match_parent" android:layout_weight="1" android:orientation="vertical" android:layout_height="match_parent"> <ImageView android:id="@+id/imageView_2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/selector_2" /> </LinearLayout> <!--android:id="@+id/threeLinearLayout"--> <LinearLayout android:id="@+id/threeLinearLayout" android:layout_margin="1dp" android:layout_width="match_parent" android:layout_weight="1" android:orientation="vertical" android:layout_height="match_parent"> <ImageView android:id="@+id/imageView_3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/selector_3" /> </LinearLayout> </LinearLayout></RelativeLayout>MainActivity.java:
点击ImageView_1:
imageView_1.setSelected(true);imageView_2.setSelected(false);imageView_3.setSelected(false);
点击ImageView_2:
imageView_1.setSelected(false);imageView_2.setSelected(true);imageView_3.setSelected(false);
点击ImageView_3:
imageView_1.setSelected(false);imageView_2.setSelected(false);imageView_3.setSelected(true);
1 0
- Android开发-selector-setSelected-AndroidStudio
- Android中Selector的setSelected“方法不管用”
- Android selector配合setSelected使用时的坑
- android setSelected(true)无效
- setSelected(boolean selected) 和selector 的使用
- android开发(selector)
- Android样式开发--selector
- Android开发-TextViewDemo-AndroidStudio
- Android开发-EditTextDemo-AndroidStudio
- Android开发-ImageViewDemo-AndroidStudio
- android setSelected及view相关知识
- Android开发笔记---- selector不起作用
- Android样式开发之selector
- Android样式的开发:selector
- Android样式开发--selector篇
- Android 开发之 selector 篇
- Android开发中Androidstudio快捷键
- Android 开发环境搭建(AndroidStudio)
- Linux下如何查看tomcat是否启动
- workflow标准活动
- Android JUnit Test for Eclipse使用入门
- 江西SEO:其实豆瓣推广可以这样做
- Activity基础回顾
- Android开发-selector-setSelected-AndroidStudio
- uva10340 (字符串模拟)
- 任务1:搭建Java开发环境
- Java实现公众号H5 微信支付
- Python轻松上阵的法器
- ORA-00955:名称已由现有对象使用
- [Android]AIDL详解【上】
- DB time VS. DB CPU
- html笔记