首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >android switch thumb文本截断

android switch thumb文本截断
EN

Stack Overflow用户
提问于 2016-02-17 03:34:38
回答 1查看 880关注 0票数 0

我想在我的应用程序中实现一个切换窗口小部件,并且该功能工作得很好。开关的问题是拇指上的off文本("OFF")。"OFF“比拇指的大小更大。我想增加拇指的大小(或减少拇指文本),但由于某种奇怪的原因,我无法做到这两个。看起来是这样的:

开关的关闭状态

屏幕截图

下面是XML文件:

代码语言:javascript
复制
   <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    android:id="@+id/gameSettingsContainer"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true"
    tools:context="com.example.vb1115.multchoicequestion.LaunchScreen">
    <LinearLayout
        android:id="@+id/lessonModeSliderContainer"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true">
        <Switch
            android:id="@+id/lessonModeToggleSlider"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:showText="true"/>
    </LinearLayout>
    <ImageView
        android:id="@+id/lessonModeAnimatedArrow"
        android:src="@mipmap/green_arrow"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_toLeftOf="@id/lessonModeSliderContainer"/>
</RelativeLayout>

我不认为代码本身有问题。我在我的活动代码中所做的一切就是查找切换视图来修改setOnCheckedChangeListener方法。

EN

回答 1

Stack Overflow用户

发布于 2016-02-17 14:11:44

您可以尝试在Switch标记上设置android:textSize,如下所示:

代码语言:javascript
复制
    <Switch
        android:id="@+id/lessonModeToggleSlider"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:textSize="text_size_here" <----- this line
        android:showText="true"/>

Switch类扩展了CompoundButton,后者扩展了Button,后者扩展了TextView,从而使这成为可能。您还可以尝试在代码中使用setTextSize()方法以编程方式设置文本大小。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35441529

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档