2016-07-03 6 views
2

Androidボタンが使用しているデフォルトのマージンを削除するにはどうすればよいですか?私は、ボタンの幅(画面の端とボタンの間にスペースが全くない)と、それらの間にスペースがないようにします。私はパディングを設定していませんが、パディングがあるようです。Androidボタンからマージンを削除する

私は、テーマテーマの親として "Theme.AppCompat.Light.NoActionBar"を使用しています。 X方向の

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 
    <Button 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 

    <Button 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 
</LinearLayout> 

Screenshot showing the default margin android buttons have

+2

これは、おそらくボタンの背景から来ています。 – CommonsWare

+0

これに提供されたソリューションの1つを使用しましたか? – Geoff

+0

彼らを試してみましたが、私は彼らが欲しいのと同じように動作しません。私はここから背景としてカスタムリップル効果を使用して終了しました:http://stackoverflow.com/a/26349261/2456568 – Mike

答えて

-1

スケールあなたのボタン:android:scaleX="1.05"

1

ボタンxmlで以下のように使用して、表示方法を変更する他の機能を変更します。 アンドロイドminHeightプロパティ= 0:のminWidth = 0がボタンからmarging余分削除する

style="?android:attr/buttonBarButtonStyle" 
-2

あなたは アンドロイドを使用することができます。

+1

余白ではなく、パディングを削除するために使用されます。 – Abhilash

0

私は同じ問題がありました。デフォルトのボタンにはマージンが付いています。次のようなボタンプロパティを設定します。

android:layout_marginTop="-3dp" 

左、右、下の余白についても同じ操作を行います。または、次のパラメータを使用して新しいドロウアブルを定義します。

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle" 
    android:padding="10dp" 
    > 
    <solid android:color="@color/colorButtonGray"/> 
    <corners 
     android:bottomRightRadius="2dp" 
     android:bottomLeftRadius="2dp" 
     android:topLeftRadius="2dp" 
     android:topRightRadius="2dp"/> 
</shape> 

カスタムシェイプには余白が組み込まれません。

関連する問題