标签:android style blog class c code
介绍一个
1.grid layout item顺序显示的代码
2.grid layout item随机显示的代码
3.grid layout item到序显示的代码
4.grid layout item方式显示
LayoutAnimation1.java
/* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.example.android.apis.view; import com.example.android.apis.R; import android.app.Activity; import android.content.Intent; import android.content.pm.ResolveInfo; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.GridView; import android.widget.ImageView; import java.util.List; public class LayoutAnimation1 extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); loadApps(); setContentView(R.layout.layout_animation_1); GridView grid = (GridView) findViewById(R.id.grid); grid.setAdapter(new LayoutAnimation1.AppsAdapter()); } private List<ResolveInfo> mApps; private void loadApps() { Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); mApps = getPackageManager().queryIntentActivities(mainIntent, 0); } public class AppsAdapter extends BaseAdapter { public View getView(int position, View convertView, ViewGroup parent) { ImageView i = new ImageView(LayoutAnimation1.this); ResolveInfo info = mApps.get(position % mApps.size()); i.setImageDrawable(info.activityInfo.loadIcon(getPackageManager())); i.setScaleType(ImageView.ScaleType.FIT_CENTER); final int w = (int) (36 * getResources().getDisplayMetrics().density + 0.5f); i.setLayoutParams(new GridView.LayoutParams(w, w)); return i; } public final int getCount() { return Math.min(32, mApps.size()); } public final Object getItem(int position) { return mApps.get(position % mApps.size()); } public final long getItemId(int position) { return position; } } }layout_animation_1.xml
<GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/grid" android:layoutAnimation="@anim/layout_grid_fade" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="10dp" android:verticalSpacing="10dp" android:horizontalSpacing="10dp" android:numColumns="auto_fit" android:columnWidth="60dp" android:stretchMode="columnWidth" android:gravity="center" />
<gridLayoutAnimation xmlns:android="http://schemas.android.com/apk/res/android" android:rowDelay="50%" android:directionPriority="column" android:animation="@anim/fade" />
如果把 android:directionPriority="column"
修改为android:animationOrder="random"则为随机显示
修改为android:directionPriority="row"
android:direction="right_to_left|bottom_to_top"倒序显示
<alpha xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator" android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="@android:integer/config_longAnimTime" />
上面本来是个gif格式的图片不知道卫生传上去后不显示
改为水印方式首先修改layout文件为
layout_animation_6xml
<GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/grid" android:layoutAnimation="@anim/layout_wave_scale" android:layout_width="match_parent" android:layout_height="match_parent" android:verticalSpacing="10dp" android:horizontalSpacing="10dp" android:numColumns="auto_fit" android:columnWidth="60dp" android:stretchMode="columnWidth" android:gravity="center" />
<gridLayoutAnimation xmlns:android="http://schemas.android.com/apk/res/android" android:rowDelay="75%" android:columnDelay="0%" android:directionPriority="none" android:animation="@anim/wave_scale" />
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="100" /> <scale android:fromXScale="0.5" android:toXScale="1.5" android:fromYScale="0.5" android:toYScale="1.5" android:pivotX="50%" android:pivotY="50%" android:duration="200" /> <scale android:fromXScale="1.5" android:toXScale="1.0" android:fromYScale="1.5" android:toYScale="1.0" android:pivotX="50%" android:pivotY="50%" android:startOffset="200" android:duration="100" /> </set>
C1000k 新思路:用户态 TCP/IP 协议栈,布布扣,bubuko.com
标签:android style blog class c code
原文地址:http://blog.csdn.net/solstice/article/details/26363901