Skip to content

Instantly share code, notes, and snippets.

@slumbers99
Created December 14, 2013 17:09
<?xml version="1.0" encoding="utf-8"?>
<!-- 作った shape を元に clip を作る -->
<clip xmlns:android="http://schemas.android.com/apk/res/android"
android:clipOrientation="vertical"
android:drawable="@drawable/shape_oval_text_background"
android:gravity="bottom|clip_vertical" />
<!-- TextView の背景に clip を指定 -->
<TextView
android:id="@+id/text_view"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_centerInParent="true"
android:background="@drawable/clip_text_background"
android:gravity="bottom|center_horizontal"
android:paddingBottom="30dp"
android:text="@string/hello_world"
android:textColor="#FF0000"
android:textSize="22sp" />
// ClipDrawable を持ってきてレベルを指定
TextView textView = (TextView) this.findViewById(R.id.text_view);
ClipDrawable background = (ClipDrawable) textView.getBackground();
background.setLevel(background.getLevel() + 2500);
<?xml version="1.0" encoding="utf-8"?>
<!-- 円形の shape を作る -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<solid android:color="#8000FF00" />
<stroke
android:width="5dp" />
</shape>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment