Skip to content

Instantly share code, notes, and snippets.

View hangox's full-sized avatar
🤒
Out sick

hangox

🤒
Out sick
View GitHub Profile
@hangox
hangox / Kirito.java
Last active August 29, 2015 14:12
分享文字,打开选择dialog
/**
* 打开分享选择dialog
* @param context
* @param message
* @param title
*/
public static void shareMessageUsedChooser(Context context, String message, String title){
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
@hangox
hangox / MyViewPager.java
Created January 7, 2015 07:14
一个自适应内部内容的ViewPager写法,缺陷就是,过渡是闪烁的
package com.chezanw.wz.widget;
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import com.hangox.xlog.XLog;
@hangox
hangox / openMapIntent
Created January 7, 2015 07:22
通过intent查看地图
// Map point based on address
Uri location = Uri.parse("geo:0,0?q=1600+Amphitheatre+Parkway,+Mountain+View,+California");
// Or map point based on latitude/longitude
// Uri location = Uri.parse("geo:37.422219,-122.08364?z=14"); // z param is zoom level
Intent mapIntent = new Intent(Intent.ACTION_VIEW, location);
@hangox
hangox / gist:b5077a9cf3f0cb2e6c7b
Created January 7, 2015 07:25
如何通过intent打开一个activity
// Build the intent
Uri location = Uri.parse("geo:0,0?q=1600+Amphitheatre+Parkway,+Mountain+View,+California");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, location);
// Verify it resolves
PackageManager packageManager = getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(mapIntent, 0);
boolean isIntentSafe = activities.size() > 0;
// Start an activity if it's safe
@hangox
hangox / styles.xml
Created January 13, 2015 07:15
如何在v21 appcompact上修改Actionbar title,颜色,字体颜色
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#FF3333</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="colorPrimaryDark">#FF3333</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="colorAccent">#FFF</item>
</style>
@hangox
hangox / gist:984ab73d925df9b5e4be
Last active August 29, 2015 14:13
5.0上windowcontentoverlay 要注意的东西
Why does my Action Bar have a shadow on Android Lollipop? I’ve set android:windowContentOverlay to null.
On Lollipop, the action bar shadow is provided using the new elevation API.
To remove it, either call getSupportActionBar().setElevation(0),
or set the elevation attribute in your Action Bar style.
[链接] (http://android-developers.blogspot.com/2014/10/appcompat-v21-material-design-for-pre.html)
@hangox
hangox / styles.xml
Created February 4, 2015 08:19
分享一个radiobutton作为tab的style,最重要的死后paddingleft = 0 这一句,解决了有些机子上会出现偏右的情况
<style name="tab">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">0dp</item>
<item name="android:layout_weight">1</item>
<item name="android:textSize">14sp</item>
<item name="android:button">@null</item>
<item name="android:textColor">@color/tab_text_color</item>
<item name="android:gravity">center_horizontal</item>
<item name="android:paddingLeft">0dp</item>
</style>
@hangox
hangox / activity_main.xml
Created February 9, 2015 15:17
这个开关的动画还不错
<android.support.v7.widget.SwitchCompat
android:layout_width="match_parent"
android:layout_height="match_parent"/>
@hangox
hangox / Dp2px
Created April 11, 2015 10:13
一个Android中dp2px代码
public static int dpToPx(Context context,float dpValue) {
final float scale =context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
@hangox
hangox / MainActivity.java
Created July 17, 2015 01:51
更改5.0statusbar 为透明颜色
View statusBar = getWindow().getDecorView().findViewById(android.R.id
.statusBarBackground);
statusBar.setBackgroundResource(android.R.color.transparent);