Ticker

6/recent/ticker-posts

Example of using "?android:attr/selectableItemBackground" and "?android:attr/selectableItemBackgroundBorderless"


Example to apply "?android:attr/selectableItemBackground" and "?android:attr/selectableItemBackgroundBorderless" to android:background, in XML file.
  • ?android:attr/selectableItemBackground for a bounded ripple.
  • ?android:attr/selectableItemBackgroundBorderless for a ripple that extends beyond the view. It will be drawn upon, and bounded by, the nearest parent of the view with a non-null background. (introduced in API level 21)
reference: http://developer.android.com/training/material/animations.html#Touch


    xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="30dp"
android:orientation="vertical"
tools:context=".MainActivity">
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:autoLink="web"
android:text="http://picturedmagazine.blogspot.com/"
android:textStyle="bold" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="30dp"
android:orientation="vertical">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Normal Button"/>
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="\?android:attr/selectableItemBackground"
android:textAllCaps="false"
android:background="?android:attr/selectableItemBackground" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="\?android:attr/selectableItemBackgroundBorderless"
android:textAllCaps="false"
android:background="?android:attr/selectableItemBackgroundBorderless" />

android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="30dp"
android:orientation="vertical"
android:background="#80C0C0">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Normal Button"/>
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="\?android:attr/selectableItemBackground"
android:textAllCaps="false"
android:background="?android:attr/selectableItemBackground" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="\?android:attr/selectableItemBackgroundBorderless"
android:textAllCaps="false"
android:background="?android:attr/selectableItemBackgroundBorderless" />

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@mipmap/ic_launcher"
android:clickable="true"
android:background="?android:attr/selectableItemBackgroundBorderless" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@mipmap/ic_launcher"
android:clickable="true"
android:background="?android:attr/selectableItemBackgroundBorderless" />



إرسال تعليق

0 تعليقات