Skip to content

Instantly share code, notes, and snippets.

@ahmadronaghdev
Forked from granoeste/activity_main.xml
Created February 5, 2018 19:13
Show Gist options
  • Select an option

  • Save ahmadronaghdev/e31c935d9c999218087ce1b89cacf3ea to your computer and use it in GitHub Desktop.

Select an option

Save ahmadronaghdev/e31c935d9c999218087ce1b89cacf3ea to your computer and use it in GitHub Desktop.

Revisions

  1. @granoeste granoeste revised this gist Sep 5, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion button_selector.xml
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    <!-- Inactive -->
    <item android:drawable="@drawable/button_unselected" android:state_enabled="true" android:state_focused="false" android:state_pressed="false" android:state_selected="false"/>
    <!-- Pressed -->
    <item android:drawable="@drawable/button_selected" android:state_enabled="true" android:state_focused="true" android:state_pressed="true" />
    <item android:drawable="@drawable/button_selected" android:state_enabled="true" android:state_focused="false" android:state_pressed="true" />
    <!-- Selected (using d-pad) -->
    <item android:drawable="@drawable/button_selected" android:state_enabled="true" android:state_focused="true" android:state_pressed="false" android:state_selected="true"/>
    <!-- Disable -->
  2. @granoeste granoeste revised this gist Aug 21, 2012. 1 changed file with 11 additions and 9 deletions.
    20 changes: 11 additions & 9 deletions button_selector.xml
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,15 @@
    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- Active tab -->
    <item android:drawable="@drawable/button_selected" android:state_focused="false" android:state_pressed="false" android:state_selected="true"/>
    <!-- Inactive tab -->
    <item android:drawable="@drawable/button_unselected" android:state_focused="false" android:state_pressed="false" android:state_selected="false"/>
    <!-- Pressed tab -->
    <item android:drawable="@drawable/button_selected" android:state_pressed="true"/>
    <!-- Selected tab (using d-pad) -->
    <item android:drawable="@drawable/button_selected" android:state_focused="true" android:state_pressed="false" android:state_selected="true"/>

    <!-- Active -->
    <item android:drawable="@drawable/button_selected" android:state_enabled="true" android:state_focused="false" android:state_pressed="false" android:state_selected="true"/>
    <!-- Inactive -->
    <item android:drawable="@drawable/button_unselected" android:state_enabled="true" android:state_focused="false" android:state_pressed="false" android:state_selected="false"/>
    <!-- Pressed -->
    <item android:drawable="@drawable/button_selected" android:state_enabled="true" android:state_focused="true" android:state_pressed="true" />
    <!-- Selected (using d-pad) -->
    <item android:drawable="@drawable/button_selected" android:state_enabled="true" android:state_focused="true" android:state_pressed="false" android:state_selected="true"/>
    <!-- Disable -->
    <item android:drawable="@drawable/button_disabled" android:state_enabled="false"/>

    </selector>
  3. @granoeste granoeste created this gist Aug 13, 2012.
    15 changes: 15 additions & 0 deletions activity_main.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    <Button
    android:id="@+id/button1"
    style="@style/GlossyGradientButtonStyle"
    android:layout_width="wrap_content"
    android:layout_height="@dimen/button_height"
    android:minWidth="100dp"
    android:text="OK" />

    <Button
    android:id="@+id/button2"
    style="@style/GlossyGradientButtonStyle"
    android:layout_width="wrap_content"
    android:layout_height="@dimen/button_height"
    android:minWidth="100dp"
    android:text="やれやれだぜ" />
    44 changes: 44 additions & 0 deletions button_selected.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <!-- くぼみ -->
    <item>
    <shape android:shape="rectangle" >
    <corners android:radius="@dimen/button_radius" />
    <solid android:color="#3D3D3D" />
    </shape>
    </item>

    <!-- グラデーション下地 -->
    <item
    android:bottom="@dimen/button_inner_margin"
    android:left="@dimen/button_inner_margin"
    android:right="@dimen/button_inner_margin"
    android:top="@dimen/button_inner_margin">
    <shape android:shape="rectangle" >
    <corners android:radius="@dimen/button_inner_radius" />
    <gradient
    android:angle="270"
    android:endColor="#7B7B7B"
    android:startColor="#6A6A6A"
    android:type="linear" />
    </shape>
    </item>

    <!-- グラデーション陰影 -->
    <item
    android:bottom="@dimen/button_inner_margin"
    android:left="@dimen/button_inner_margin"
    android:right="@dimen/button_inner_margin"
    android:top="@dimen/button_glossy_marginTop">
    <shape android:shape="rectangle" >
    <corners
    android:bottomLeftRadius="@dimen/button_inner_radius"
    android:bottomRightRadius="@dimen/button_inner_radius"
    android:topLeftRadius="0dp"
    android:topRightRadius="0dp" />
    <solid android:color="#60000000" />
    </shape>
    </item>

    </layer-list>
    13 changes: 13 additions & 0 deletions button_selector.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- Active tab -->
    <item android:drawable="@drawable/button_selected" android:state_focused="false" android:state_pressed="false" android:state_selected="true"/>
    <!-- Inactive tab -->
    <item android:drawable="@drawable/button_unselected" android:state_focused="false" android:state_pressed="false" android:state_selected="false"/>
    <!-- Pressed tab -->
    <item android:drawable="@drawable/button_selected" android:state_pressed="true"/>
    <!-- Selected tab (using d-pad) -->
    <item android:drawable="@drawable/button_selected" android:state_focused="true" android:state_pressed="false" android:state_selected="true"/>

    </selector>
    44 changes: 44 additions & 0 deletions button_unselected.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <!-- くぼみ -->
    <item>
    <shape android:shape="rectangle" >
    <corners android:radius="@dimen/button_radius" />
    <solid android:color="#5D5D5D" />
    </shape>
    </item>

    <!-- グラデーション下地 -->
    <item
    android:bottom="@dimen/button_inner_margin"
    android:left="@dimen/button_inner_margin"
    android:right="@dimen/button_inner_margin"
    android:top="@dimen/button_inner_margin">
    <shape android:shape="rectangle" >
    <corners android:radius="@dimen/button_inner_radius" />
    <gradient
    android:angle="270"
    android:endColor="#D9D9D9"
    android:startColor="#F7F7F7"
    android:type="linear" />
    </shape>
    </item>

    <!-- グラデーション陰影 -->
    <item
    android:bottom="@dimen/button_inner_margin"
    android:left="@dimen/button_inner_margin"
    android:right="@dimen/button_inner_margin"
    android:top="@dimen/button_glossy_marginTop">
    <shape android:shape="rectangle" >
    <corners
    android:bottomLeftRadius="@dimen/button_inner_radius"
    android:bottomRightRadius="@dimen/button_inner_radius"
    android:topLeftRadius="0dp"
    android:topRightRadius="0dp" />
    <solid android:color="#20000000" />
    </shape>
    </item>

    </layer-list>
    14 changes: 14 additions & 0 deletions dimens.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    <resources>

    <!-- Button -->
    <dimen name="button_height">48dp</dimen> <!-- ボタンの高さ -->
    <dimen name="button_radius">15dp</dimen> <!-- くぼみの丸み -->
    <dimen name="button_inner_radius">11dp</dimen> <!-- ボタンの丸み -->
    <dimen name="button_inner_margin">4dp</dimen> <!-- ボタンのマージン(くぼみの太さ) -->
    <dimen name="button_glossy_marginTop">24dp</dimen> <!-- ボタンの光沢グラデーション位置(ボタンの高さの中央値) -->
    <dimen name="button_content_paddingLeft">8dp</dimen> <!-- ボタン内の文字の左部パディング -->
    <dimen name="button_content_paddingRight">8dp</dimen> <!-- ボタン内の文字の右部パディング -->
    <dimen name="button_content_paddingTop">4dp</dimen> <!-- ボタン内の文字の上部パディング -->
    <dimen name="button_content_paddingBottom">4dp</dimen> <!-- ボタン内の文字の下部パディング -->

    </resources>
    16 changes: 16 additions & 0 deletions styles.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    <resources xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- Glossy Gradient Button Style -->
    <style name="GlossyGradientButtonStyle" parent="@android:style/Widget.Button">
    <item name="android:background">@color/button_selector</item>
    <item name="android:shadowColor">#979797</item>
    <item name="android:shadowRadius">3.0</item>
    <item name="android:shadowDx">-0.5</item>
    <item name="android:shadowDy">-0.5</item>
    <item name="android:paddingLeft">@dimen/button_content_paddingLeft</item>
    <item name="android:paddingRight">@dimen/button_content_paddingRight</item>
    <item name="android:paddingTop">@dimen/button_content_paddingTop</item>
    <item name="android:paddingBottom">@dimen/button_content_paddingBottom</item>
    </style>

    </resources>