admin管理员组文章数量:1288075
i want to make Switch width shorter and height longer. But it isn't work. Below is my xml code.
// layout_custom_switch
<LinearLayout xmlns:android=";
xmlns:app=";
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/widget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:thumb="@drawable/shape_switch_thumb"
app:track="@drawable/selector_switch"/>
</LinearLayout>
// shape_switch_thumb
<shape xmlns:android=";
android:shape="oval">
<size android:width="16dp" android:height="16dp"/>
<solid android:color="#FFFFFF"/>
<stroke android:width="8dp" android:color="#00FFFFFF"/>
</shape>
// selector_switch
<selector xmlns:android=";>
<item android:drawable="@drawable/bg_switch_track_on" android:state_checked="true"/>
<item android:drawable="@drawable/bg_switch_track_off" android:state_checked="false"/>
</selector>
// bg_switch_track_on
<shape xmlns:android=";
android:shape="rectangle">
<corners android:radius="30dp"/>
<size android:width="16dp" android:height="24dp" />
<solid android:color="#927448"/>
</shape>
// bg_switch_track_off
<shape xmlns:android=";
android:shape="rectangle">
<corners android:radius="30dp"/>
<size android:width="16dp" android:height="24dp" />
<solid android:color="#BBAB94"/>
</shape>
when i change the bg_switch_track_on(off) android:height = "24dp" thumb's width and height is same (16dp) but, looks oval. how can i make width shorter and height longer?
enter image description here
i tried to find solution about customizing switchcompat widget but, there was not design with shorter width and longer height
本文标签: androidCustomizing SwitchCompatStack Overflow
版权声明:本文标题:android - Customizing SwitchCompat - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741334648a2372969.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论