11
A
答えて
14
このスタイルを継承する必要があります。
あなたのstyles.xmlに追加:あなたのレイアウトで
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid
android:color="@color/colorAccent" >
</solid>
<corners
android:radius="11dp" >
</corners>
</shape>
そして最後に:
<style name="AppTheme.RoundedCornerMaterialButton" parent="Widget.AppCompat.Button.Colored">
<item name="android:background">@drawable/rounded_shape</item>
</style>
は、ファイルの描画可能/ rounded_shape.xmlを追加
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test Text"
style="@style/AppTheme.RoundedCornerMaterialButton"/>
編集:更新された答えをハードコードされたものではなく、テーマの色を使用する。
0
はまた別の簡単な方法は、cardViewのまわりでそれを包むwrap_contentするcardViewのlayout_widthとlayout_heightを設定することを忘れないでくださいある、また、ボタンは必要なすべての必要なマージンがcardView
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardCornerRadius="8dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="40dp"
app:elevation="10dp">
<android.support.v7.widget.AppCompatButton
android:id="@+id/login_twitter"
android:tag="login_twitter"
android:layout_width="300dp"
android:layout_height="60dp"
android:paddingLeft="10dp"
android:foreground="?attr/selectableItemBackgroundBorderless"
android:textColor="@color/blue_grey_ligthen_5"
android:drawableLeft="@drawable/twitter"
android:background="@color/twitter"
android:text="@string/login_with_twitter" />
</android.support.v7.widget.CardView>
0
Iに適用されなければなりませんこのための私の正確な解決策を教えてくれます。セレクタタグ内では、アイテムを配置できます(ボタンの機能)
セレクタタグの2番目の項目の動作は逆です。背景=「描画可能/このXML @」
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#ffffff"> <!-- this is the ripple color(first touch color changes into this color) -->
<item>
<selector>
<item android:state_enabled="true">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- default button color -->
<solid android:color="@color/colorPrimary"></solid>
<corners android:radius="151dp"></corners>
</shape>
</item>
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- button disabled color opposite behaviour -->
<solid android:color="#e9d204"></solid>
<corners android:radius="151dp"></corners>
</shape>
</item>
</selector>
</item>
<item>
<selector>
<item android:state_pressed="true">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- button first touch of your finger color -->
<solid android:color="#1989fa"></solid>
<corners android:radius="151dp"></corners>
</shape>
</item>
</selector>
</item>
<item>
<selector>
<item android:state_hovered="true">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- hovered with a note pencil -->
<solid android:color="#4affffff"></solid>
<corners android:radius="151dp"></corners>
</shape>
</item>
</selector>
</item>
</ripple>
関連する問題
- 1. 角度材料
- 2. 角材料タブ
- 3. 角度材料近いmdDialog
- 4. 角度材料 - Datepicker
- 5. 角度材料で
- 6. 角材料を使用しない角材チップの効果
- 7. 角度材料デザインのフレックスカード
- 8. 角材料固定側-NAV
- 9. 角度材料css md-autocomplete:focus
- 10. 角度材料カレンダーの使い方
- 11. IEのボタンの丸い角
- 12. タブ使用ボタンは、私は、角+角度材料を使用しています
- 13. 角度-材料は、私は、角1.5.9 &角度材料設計を使用してい
- 14. 角材料ボタンからコントローラに情報を渡す
- 15. 角度のある材料のタブカスタムHTML
- 16. 角度材料の右サイドバーの問題
- 17. 角度材料Iは、角材料datapickerとの基本的な例を持っている
- 18. UIブートストラップと角度の材料
- 19. 角度材料のオートコンプリート、需要
- 20. 角度材料データテーブル内の内容
- 21. 角度2の材料タブとngForm
- 22. は、どのような角度-材料
- 23. 行ごとの角材料入力
- 24. 角度材料日付ピッカーフィールド値空
- 25. は、ダーツ、角2材料から
- 26. 更新角度材料モーダルUI
- 27. HTML5ビデオレイアウト充填角度材料
- 28. 角2カード付き材料グリッドリスト
- 29. 角型材料でオートマッチするタイプヘッド
- 30. 角度材料とmd-iconディレクティブ
はしかし、これはボタンの波及効果を取り除く:あなたは がBUTTONアンドロイドの背景として、この描画可能なXMLを追加セレクタ(ボタンの動作)と同じくらいを追加することができます。どのようにカスタマイズされたボタンに波及効果を得るには? – ssudaraka
@SupunSudaraka http://stackoverflow.com/a/24530169/401025 –
@LostinBielefeldありがとう、私はこれを試してみます。 – ssudaraka