Skip to content

Instantly share code, notes, and snippets.

View zstartw's full-sized avatar
🌴
On vacation

Just do it zstartw

🌴
On vacation
View GitHub Profile
@zstartw
zstartw / design.xml
Last active December 17, 2015 06:08
Material design
<!--get from googlesamples -->
<!--Material BorderlessImageButton -->
<ImageButton android:id="@+id/secondary_action"
style="?android:borderlessButtonStyle"
android:layout_width="@dimen/standard_touch_target_size"
android:layout_height="match_parent"
android:src="@drawable/ic_action_delete"
android:contentDescription="@string/delete_content_description" />
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:color="#C7B299"
android:dashWidth="10px"
android:dashGap="10px"
android:width="1dp"/>
</shape>
ObjectAnimator 使用的属性介绍:
translationX,translationY: View相对于原始位置的偏移量
rotation,rotationX,rotationY: 旋转,rotation用于2D旋转角度,3D中用到后两个
scaleX,scaleY: 缩放比
x,y: View的最终坐标,是View的left,top位置加上translationX,translationY
alpha: 透明度
TimeInterplator:
@zstartw
zstartw / MyScrollView.java
Created January 27, 2016 09:54
Custom Scroll detect Scroll up、down、stop
package com.example.betterzw.myapplication;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.ScrollView;
/**
* Created by betterzw on 16-1-27.
@zstartw
zstartw / Spinner.java
Created January 28, 2016 03:02
修改点击Spinner 显示PopupWindow高度
Spinner spinner = (Spinner) findViewById(R.id.spinner);
try {
Field popup = Spinner.class.getDeclaredField("mPopup");
popup.setAccessible(true);
// Get private mPopup member variable and try cast to ListPopupWindow
android.widget.ListPopupWindow popupWindow = (android.widget.ListPopupWindow) popup.get(spinner);
// Set popupWindow height to 500px
popupWindow.setHeight(500);
@zstartw
zstartw / InputStream.java
Last active February 25, 2016 08:55
网络输入流
final URL location = new URL(FEED_URL);
InputStream stream = null;
try {
Log.i(TAG, "Streaming data from network: " + location);
stream = downloadUrl(location);
updateLocalFeedData(stream, syncResult);
// Makes sure that the InputStream is closed after the app is
// finished using it.
} finally {
@zstartw
zstartw / layout_configue.xml
Last active February 26, 2016 09:44
配制文件
一、TextView
android:autoLink="all" //自动添加超链接
二、代码中添加字体的属性
SpannableString ss = new SpannableString(
"text_spannable: Manually created spans. Click here to dial the phone.");
//加粗
ss.setSpan(new StyleSpan(Typeface.BOLD), 0, 39,
Spanned.SPAN_INCLUSIVE_INCLUSIVE);
//特定的字符添加超链接
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:card_view="http://schemas.android.com/tools"
android:orientation="vertical">
<include layout="@layout/view_feed_toolbar" />
<android.support.design.widget.TabLayout
android:id="@+id/home_tab_tab"
style="@style/customTabLayout"
app:tabMode="scrollable" />
<style name="customTabLayout" parent="Widget.Design.TabLayout">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">45dip</item>
public class ArithUtils {
/**
* 提供精确的加法运算。
*
* @param v1 被加数
* @param v2 加数
* @return 两个参数的和
*/
public static double add(double v1, double v2) {