Api23/UI
// Set the Action Bar to use tabs for navigation | |
ActionBar ab = getSupportActionBar(); | |
ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); | |
// Add three tabs to the Action Bar for display | |
ab.addTab(ab.newTab().setText("Tab 1").setTabListener(this)); //ActionBar.TabListener | |
ab.addTab(ab.newTab().setText("Tab 2").setTabListener(this)); | |
ab.addTab(ab.newTab().setText("Tab 3").setTabListener(this)); |
public class CheckableLinearLayout extends LinearLayout implements Checkable { | |
private static final int[] CHECKED_STATE_SET = {android.R.attr.state_checked}; | |
private boolean mChecked = false; | |
public CheckableLinearLayout(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} | |
public boolean isChecked() { | |
return mChecked; | |
} | |
public void setChecked(boolean b) { | |
if (b != mChecked) { | |
mChecked = b; | |
refreshDrawableState(); | |
} | |
} | |
public void toggle() { | |
setChecked(!mChecked); | |
} | |
@Override | |
public int[] onCreateDrawableState(int extraSpace) { | |
final int[] drawableState = super.onCreateDrawableState(extraSpace + 1); | |
if (isChecked()) { | |
mergeDrawableStates(drawableState, CHECKED_STATE_SET); | |
} | |
return drawableState; | |
} | |
} |
//From api23/ui/BassicAccessibility/DialView.java | |
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); //触发AccessibilityEvent | |
@Override | |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) | |
public void onPopulateAccessibilityEvent(AccessibilityEvent event) { | |
super.onPopulateAccessibilityEvent(event); | |
// Detect what type of accessibility event is being passed in. | |
int eventType = event.getEventType(); | |
// Common case: The user has interacted with our view in some way. State may or may not | |
// have been changed. Read out the current status of the view. | |
// We also set some other metadata which is not used by TalkBack, but could be used by | |
// other TTS engines. | |
if (eventType == AccessibilityEvent.TYPE_VIEW_SELECTED || | |
eventType == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED) { | |
event.getText().add("Mode selected: " + Integer.toString(mActiveSelection + 1) + "."); | |
event.setItemCount(SELECTION_COUNT); | |
event.setCurrentItemIndex(mActiveSelection); | |
} | |
// When a user first focuses on our view, we'll also read out some simple instructions to | |
// make it clear that this is an interactive element. | |
if (eventType == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED) { | |
event.getText().add("Tap to change."); | |
} | |
} |
Notification createNotification(boolean makeHeadsUpNotification) { | |
Notification.Builder notificationBuilder = new Notification.Builder(getActivity()) | |
.setSmallIcon(R.drawable.ic_launcher_notification) | |
.setPriority(Notification.PRIORITY_DEFAULT) | |
.setCategory(Notification.CATEGORY_MESSAGE) | |
.setContentTitle("Sample Notification") | |
.setContentText("This is a normal notification."); | |
if (makeHeadsUpNotification) { | |
Intent push = new Intent(); | |
push.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |
push.setClass(getActivity(), LNotificationActivity.class); | |
PendingIntent fullScreenPendingIntent = PendingIntent.getActivity(getActivity(), 0, | |
push, PendingIntent.FLAG_CANCEL_CURRENT); | |
notificationBuilder | |
.setContentText("Heads-Up Notification on Android L or above.") | |
.setFullScreenIntent(fullScreenPendingIntent, true); | |
} | |
return notificationBuilder.build(); | |
} |
//leanback mode | |
int uiOptions = flagsView.getSystemUiVisibility(); | |
uiOptions &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE; | |
uiOptions |= View.SYSTEM_UI_FLAG_FULLSCREEN; | |
uiOptions |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; | |
uiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE; | |
uiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; | |
flagsView.setSystemUiVisibility(uiOptions); | |
//Immersive mode | |
int uiOptions = flagsView.getSystemUiVisibility(); | |
uiOptions &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE; | |
uiOptions |= View.SYSTEM_UI_FLAG_FULLSCREEN; | |
uiOptions |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; | |
uiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE; | |
uiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; | |
flagsView.setSystemUiVisibility(uiOptions); |
//nine-patch drawable Button 直接设置背景 | |
<nine-patch xmlns:android="http://schemas.android.com/apk/res/android" | |
android:src="@drawable/btn_default_normal_holo" | |
android:tint="@color/custom_tint" //看下面 | |
android:tintMode="multiply" /> | |
//custom-tint.xml | |
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | |
<!-- Pressed state --> | |
<item android:color="@color/red" android:state_pressed="true" /> | |
<!-- Focused state --> | |
<item android:color="@color/light_purple" android:state_focused="true" /> | |
<item android:color="@color/deep_purple" android:state_enabled="true" /> | |
<!-- Disabled state --> | |
<item android:color="@color/light_blue" android:state_enabled="false" /> | |
<!-- Default --> | |
<item android:color="@color/light_blue" /> | |
</selector> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment