2017-07-05 2 views
0

Screenshot私のAndroidボタンはちょっと変わって見えます(スクリーンショットが添付されています)?

私のボタンは丸くしたいが、楕円形である(スクリーンショットを見てください)。誰も助けることができますか?私のコード(下に2つのボタンがあります):

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:paddingTop="?attr/actionBarSize" 
    android:background="#ffffff" 
    > 

    <TextView 
     android:id="@+id/tv" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:paddingLeft="16dp" 
     android:paddingRight="16dp" 
     android:text="@string/package_size" 
     tools:ignore="RtlSymmetry" /> 
    <View 
     android:layout_width="fill_parent" 
     android:layout_height="2dp" 
     android:layout_marginLeft="32dp" 
     android:layout_marginRight="32dp" 
     android:background="#e9eaea"/> 
    <RadioGroup xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/radio_group" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal"> 

     <RadioButton 
      android:id="@+id/radio_small" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/small" /> 

     <RadioButton 
      android:id="@+id/radio_medium" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/medium" /> 
     <RadioButton 
      android:id="@+id/radio_large" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/large" /> 
    </RadioGroup> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:weightSum="4" 
     android:background="#e6e7e8" 
     > 
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      > 
      <Button 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/ic_minus"/> 

      <TextView android:id="@+id/text" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="0" /> 
      <Button 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/ic_plus"/> 
     </LinearLayout> 

    </LinearLayout> 
</LinearLayout> 

レイアウトを変更する必要はありますか?それともなぜ起こっているのですか?

+1

幅と高さを指定します。 –

答えて

0

使用しているプラ​​スとマイナスのアイコンは、明確な高さと幅を持っています。デフォルトのサイズより小さいレイアウトに配置すると、それ以外の場合に動作するようにバインドされます。したがって、ホルダーをアイコンサイズ以上のサイズに指定します。 あなたの場合、ボタンの直系のLinear Layoutタグの高さを指定するだけです。

+0

ボタンタグの高さと幅を指定していて、うまく動作しているようです。 –

+0

はい、それでも動作します。すばらしいです。がんばろう。 @AndreyRuzhencev –

0

ボタンの背景を設定しました。

ボタンはデフォルトでは正方形ではないため、背景はボタンのデフォルトの幅に引き伸ばされます。

したがって、幅と高さを手動で同じに設定します。

関連する問題