2017-09-06 5 views
-1

カスタムのダイアログピッカーの - と+ボタンを作成するための単純な円形ボタンを作成しました。スクリーンショット-に見られるように円形カスタムボタンのインラインアライメントタイトル

enter image description here

+少しシフトダウンおよびカスタムバックグラウンドの中央にセンタリングされていません。

私のカスタム背景はdrawable/circular_button.xmlのようになります。

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="oval"> 
    <stroke android:color="@color/colorPrimaryDark" android:width="1dp" /> 
    <solid android:color="@color/colorPrimary" /> 
    <size android:width="30sp" android:height="30sp"/> 

</shape> 

ボタンは、私は、タグminHeightについて読ん柱の一つでLinearLayout

 <Button 
      android:id="@+id/decrease_one" 
      android:layout_width="40sp" 
      android:layout_height="40sp" 
      android:layout_marginRight="20sp" 
      android:background="@drawable/rounded_button" 
      android:text="-" 
      android:textColor="@color/white" 
      android:textSize="30sp" 
      android:textStyle="bold" /> 

の内側に、このように設定されているが、それは私のproblem.Anyのアイデアを解決していませんか?

+2

バッターFlaotingActionButton –

+1

を使用すると、より効果的なカスタムボタン –

答えて

2

バッターこれが原因で、あなたのボタンのアンドロイドの起こりは、あなたのアプリケーションの依存関係に

0

'com.android.support:design:26.0.+'を追加FloatingActionButtonミニ

<android.support.design.widget.FloatingActionButton 
    android:id="@+id/activity_my_digital_executor_fabDigitalex" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    card_view:fabSize="mini" 
    card_view:srcCompat="@drawable/ic_new_plus" /> 

を使用する:TEXTSIZEは=「30sp」あなたは50SPを設定した場合、そのは、より多くのラインを下ります、 ちょうどTextviewsにあなたのボタンを変換し、アンドロイドの設定:あなたのTEXTSIZEの30spも続ける= "センター" 重力を

<TextView 
      android:id="@+id/decrease_2" 
      android:layout_width="40dp" 
      android:layout_height="40dp" 
      android:layout_marginRight="20dp" 
      android:background="@drawable/rounded_button" 
      android:text="+" 
      android:gravity="center" 
      android:textColor="@color/white" 
      android:textSize="30sp" 
      android:textStyle="bold" /> 
+1

を作成することができますが、タップすると「ハイライト」効果が失われます。 –

-1

Textviewの代わりにImageviewを使用している場合は、問題が解決されます。