10.28软件设计大赛一下代码

来源:互联网 发布:优盘数据恢复实例 编辑:程序博客网 时间:2024/06/15 23:10

切换打开fragment动态效果:

mTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);



动态滚动条

// 这个Interpolator你可以设置别的 我这里选择的是有弹跳效果的Interpolator
Interpolator polator = new BounceInterpolator();
mScroller = new Scroller(mContext, polator);

推动动画

// 推动门的动画
public void startBounceAnim(int startY, int dy, int duration) {
mScroller.startScroll(0, startY, 0, dy, duration);
invalidate();
}


字体变亮又变暗,循环动画

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >


    <alpha
        android:duration="1000"
        android:fromAlpha="0.1"
        android:repeatCount="infinite"
        android:repeatMode="reverse"
        android:toAlpha="1.0" />


</set>



一个不错的

仿iphone卡片view

https://github.com/chiemy/CardView



android屏幕操作

Activity全屏设置

方式1:AndroidManifest.xml

<activity android:name="myAcitivty"  android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />

方式2:代码实现

requestWindowFeature(Window.FEATURE_NO_TITLE);  // 隐藏标题栏

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);  // 隐藏状态栏

注意:设置全屏的俩段代码必须在setContentView(R.layout.main) 之前,不然会报错。


Activity横竖屏设置

方式1:AndroidManifest.xml

<activity android:name="myAcitivty"  android:screenOrientation="landscape" /> // 或者 “portrait

方式2:代码实现

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

获取横屏方向

int orientation = this.getResources().getConfiguration().orientation;

orientation 的常用取值可以为 ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE(横屏) 或 ActivityInfo.SCREEN_ORIENTATION_PORTRAIT(竖屏)


Activity屏幕一直显示

1:AndroidManifest.xml添加权限

<uses-permission android:name="android.permission.WAKE_LOCK" />

2:代码实现

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);





0 0