Android開源 - 好玩的下拉刷新控件,讓我們一起來回味童年
效果圖
更新日志
2016-07-28
- 當后臺線程沒有執行完畢的時候,松開手指,下拉刷新控件會回滾到游戲區域高度的位置,用戶任然可以繼續玩游戲。
- 重新整理了游戲區域中央的字符顯示邏輯,不會再出現字符閃改的問題。
2016-08-01
- 修復當后臺線程執行時間太短導致動畫執行錯誤并無法操作游戲的問題。
目前支持兩種游戲:打磚塊和打坦克 打磚塊規則簡單,沒有接住小球即GameOver; 打坦克規則為:漏掉敵方坦克超過十輛或者與敵方坦克相撞即GameOver,看看你能不能堅持三分鐘吧。嘿嘿~;
使用
布局文件中:
<com.hitomi.refresh.view.FunGameRefreshView
android:id="@+id/refresh_hit_block"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:game_type="hit_block">
<ListView
android:id="@+id/list_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none">
</ListView>
</com.hitomi.refresh.view.FunGameRefreshView>
Activity中:
refreshView = (FunGameRefreshView) findViewById(R.id.refresh_fun_game);
listView = (ListView) findViewById(R.id.list_view);
arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1, createDate());
listView.setAdapter(arrayAdapter);
refreshView.setOnRefreshListener(new FunGameRefreshView.FunGameRefreshListener() {
@Override
public void onRefreshing() {
try {
// 模擬網絡請求耗時動作
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
mHandler.sendEmptyMessage(0);
}
});
</code></pre>
Attributes
支持下拉頭部控件中游戲切換:
<attr name="game_type" format="enum">
<enum name="hit_block" value="0" />
<enum name="battle_city" value="1" />
</attr>
支持游戲中各部分模型顏色自定義:
<attr name="left_model_color" format="color" />
<attr name="middle_model_color" format="color" />
<attr name="right_model_color" format="color" />
支持HitBlock游戲中磚塊列數和小球速度自定義:
<attr name="block_horizontal_num" format="integer" />
<attr name="ball_speed" format="integer">
<enum name="low" value="3" />
<enum name="medium" value="6" />
<enum name="fast" value="9" />
</attr></code></pre>
本站原創,轉載時保留以下信息:
本文轉自:深度開源(open-open.com)
原文地址:http://www.baiduhome.net/lib/view/open1470811132130.html