如何增加文本和it之间的空间';在TextView Android中有下划线吗?
我想增加文本和下划线之间的间距。我可以改变行高,但我不改变文本和下划线之间的高度。我该怎么做如何增加文本和it之间的空间';在TextView Android中有下划线吗?,android,android-layout,android-ui,Android,Android Layout,Android Ui,我想增加文本和下划线之间的间距。我可以改变行高,但我不改变文本和下划线之间的高度。我该怎么做 private static final String FONTH_PATH = "fonts/Brandon_bld.otf"; ... selectTextView = (TextView) findViewById(R.id.selectTextView); selectTextView.setTypeface(font); SpannableString content = new Spa
private static final String FONTH_PATH = "fonts/Brandon_bld.otf";
...
selectTextView = (TextView) findViewById(R.id.selectTextView);
selectTextView.setTypeface(font);
SpannableString content = new SpannableString(getResources().getString(R.string.select_your_prove_type));
content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
selectTextView.setText(content);
...
和xml文件
<TextView
android:id="@+id/selectTextView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="536"
android:gravity="left"
android:lineSpacingMultiplier="0.8"
android:text="@string/select_your_prove_type"
android:textColor="@color/Blue"
android:textSize="@dimen/select_size" />
您可以使用可绘制文件添加自定义下划线(在我的例子中,我创建了一个阴影),并使用
android:background="@drawable/shadow_file.xml"
之后,通过在编辑文本中添加填充,可以在行和文本之间添加更多空间
android:paddingBottom="@dimen/underline_space"
并在dimens.xml文件中定义此维度
这对我很有效,我也希望你:)好的,这里有一个更完整的答案: 在styles.xml中,添加样式:
<style name="MyTour.HeadingText">
<item name="android:background">@drawable/tour_header_line_layerlist</item>
</style>
@可绘制/巡更\标题\线条\图层列表
现在创建一个包含以下内容的tour\u header\u line\u layerlist.xml文件:
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="20dp" android:drawable="@drawable/tour_header_line"/>
</layer-list>
上述内容将为该行设置20dp的页边距顶部(为了完整性,将其提取到dimen.xml)
现在创建相应的tour_header_line.xml:
<shape android:shape="line"
xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="1dp"
android:color="@color/tour_subheading_color" />
现在参照控件中的样式:
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/tour_1_heading_text"
android:id="@+id/heading_text" android:layout_gravity="center_horizontal"
style="@style/MyTour.HeadingText" //notice this
android:layout_marginTop="@dimen/margin_large"/>
如果您还有其他问题,请告诉我 只需使用
垫底
如下
<android.support.design.widget.TextInputLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<EditText
android:id="@+id/fragment_activity_edit_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="16dp"
android:hint="Description"
android:textSize="34sp"
tools:text="Secret Death Ray Design"/>
</android.support.design.widget.TextInputLayout>
在
EditText
我不知道答案,也许linespacingextra属性应该这样做,但为什么您的权重属性的值为536android:layout\u weight=“536”
?linespacingextra不适用于此问题。我根据Iphone psd分割屏幕。这个psd的高度是1136px,我的根布局权重和也是1136。谢谢你分享你的答案,但我不能理解。您是否创建了自定义编辑文本@很抱歉我的简短解释。我有一个默认的EditText,但有一个自定义下划线。您可以使用可绘制文件(在我的例子中,我创建了一个阴影)和android:background=“@drawable/shadow_file.xml”添加自定义下划线,设置此自定义下划线。使用填充后,您可以在行和文本之间添加更多的空间。您可以共享shadow_file.xml或解释如何添加它吗?如果您共享shadow_file.xml
,它会更清晰。这对android非常有用:top=“20dp”,为什么在我们更改top值时它不起作用?您在TextView中使用过它吗?我试过了,但在TextView@Uzair Mohammad上不起作用