Android 侧拉选择框
来源:互联网 发布:大数据关键技术 云计算 编辑:程序博客网 时间:2024/05/17 12:55
效果如图所示:当点击Hello World!的时候,会从右侧出现右侧显示框。点击右侧的白色区域,右侧显示框会隐藏掉。
布局文件的代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <TextView android:id="@+id/tv" android:layout_width="70dp" android:layout_height="70dp" android:text="@string/hello_world" android:gravity="center" android:layout_centerInParent="true" /> <LinearLayout android:id="@+id/ll" android:layout_width="fill_parent" android:layout_height="fill_parent" android:visibility="visible" > <LinearLayout android:id="@+id/ll_1" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:background="#ffffff" android:orientation="vertical"> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="2" android:background="#043E39" android:orientation="vertical"> </LinearLayout> </LinearLayout></RelativeLayout>主界Activity的代码:
package com.example.andemo;import android.os.Bundle;import android.app.Activity;import android.view.Menu;import android.view.View;import android.view.View.OnClickListener;import android.view.animation.Animation;import android.view.animation.TranslateAnimation;public class MainActivity extends Activity implements OnClickListener{TranslateAnimation showAnim;TranslateAnimation HiddenAnim;private View ll;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);ll = findViewById(R.id.ll);//显示的动画showAnim= new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f);//隐藏的动画HiddenAnim= new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f);//显示过程的时间showAnim.setDuration(400);//隐藏过程的时间HiddenAnim.setDuration(400);findViewById(R.id.tv).setOnClickListener(this);findViewById(R.id.ll_1).setOnClickListener(this);}@Overridepublic void onClick(View v) {// TODO Auto-generated method stubswitch (v.getId()) {case R.id.tv:ll.startAnimation(showAnim);ll.setVisibility(View.VISIBLE);break;case R.id.ll_1:ll.startAnimation(HiddenAnim);ll.setVisibility(View.GONE);break;default:break;}}}
0 0
- Android 侧拉选择框
- jQuery之下拉框左右选择
- jQuery之下拉框左右选择
- Selenium之下拉框的选择
- plsql 选择database时下拉框空白
- Android 侧拉布局
- AE要素选择(点选和拉框选择)
- AE要素选择(点选和拉框选择…
- 侧拉菜单Android动画
- Android侧拉菜单实现
- php+mcDropdown实现文件路径可在下拉框选择
- JavaScript学习笔记之下拉选择框的操作
- java通过选择年月生成天下拉框
- 两级标题栏带下拉选择框的页面刷新
- 【代码片段】demo中下拉框根据选择变化
- 上拉电阻大小选择
- Android选择框
- Android简单选择框
- qt have no compatible devices
- Android APP: Message Manager 建立资料库
- ArrayList的使用方法
- C#报表钻取子报表
- java学习——apache commons fileupload实现上传
- Android 侧拉选择框
- 用Python+Django在Eclipse环境下开发web网站
- jvm虚拟机第二章
- 微信公众号添加关注后自动回复图文信息
- quick cocos2dx FilteredSprite c++使用
- Struts2中表单数据怎样实例化
- secureCRT使用VIM时对语法高亮
- TypeError: Type str doesn't support the buffer API的解决办法
- Android Proguard原理及使用方法