2017-10-05 4 views
-1

스위치 위젯을 사용하고 있습니다. 여기에 코드안드로이드에서 스위치 위젯의 엄지 크기를 늘리는 방법은 무엇입니까?

 <Switch 
      android:id="@+id/switchFabric" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:showText="true" 

      android:switchTextAppearance="@style/SwitchTextAppearance" 
      android:text="Do you have fabric ?" 
      android:textColor="@color/black_overlay" 
      android:textOff="No" 
      android:textOn="Yes" 
      android:thumbTextPadding="@dimen/padding_4" 
      android:padding="@dimen/padding_8" 
      android:thumbTint="@color/white" 
      android:layout_marginTop="@dimen/margin_10" 
      android:layout_marginBottom="@dimen/margin_20" 
      /> 

입니다 그리고 내가 예 텍스트가 주변에 충분한 패딩을 가질 수 있도록 엄지 손가락의 크기를 증가 할이

enter image description here

나옵니다. 나는

thumbPadding

패딩 실험을 시도했다

switchMinWidth이

어떻게 이것을 달성하기 위해? 제안 사항에 감사드립니다. 미리 감사드립니다.

답변

0

스위치에 적용보다 문제는이

<style name="MySwitchStyle"> 
    <item name="android:textColor">#ffffff</item> 
    <item name="android:textSize">15sp</item> 
</style> 

같은 테마를 만들려고

<Switch 
     android:id="@+id/switchFabric" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:showText="true" 
     android:switchTextAppearance="@style/SwitchTextAppearance" 
     android:text="Do you have fabric ?" 
     android:textColor="@color/black_overlay" 
     android:textOff="No" 
     android:textOn="Yes" 
     android:scaleX="2" 
     android:scaleY="2" 
     android:thumbTextPadding="@dimen/padding_4" 
     android:padding="@dimen/padding_8" 
     android:thumbTint="@color/white" 
     app:switchTextAppearance="@style/MySwitchStyle" 
     android:layout_marginTop="@dimen/margin_10" 
     android:layout_marginBottom="@dimen/margin_20" 
     /> 
0

나는이 다음이 추가

<android.support.v7.widget.SwitchCompat 
      android:id="@+id/switch_compat2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_margin="20dp" 
      android:checked="true" 
      android:scaleX="2" 
      android:scaleY="2" 
      android:textOn="YES" 
      android:textOff="NO" 
      app:switchTextAppearance="@style/dd" 
      app:showText="true" /> 

나를 위해 일한 일을해야한다고 생각 styles.xml의 라인

<style name="dd"> 
     <item name="android:textColor">#ffffff</item> 
     <item name="android:textSize">10sp</item> 
    </style> 

당신의 필요

+1

도움이되지 않았다 아니 미안 따라 텍스트 크기와 규모의 크기를 조정합니다. 그것은 단지 텍스트의 크기를 증가 시켰습니다. –

+0

체크 아웃 내 편집 된 답변 –